SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Apr 9, 2009, 17:57 #1
- Join Date
- May 2003
- Location
- barcelona
- Posts
- 68
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
how do you: Remove an array from multiarray with a value?
I need to remove an array from a multiarray,
I have the key (ID) $post->ID, and the value (811) $thispost_id from an independent array, $post.
my second array id $posts.
PHP Code:/*
global $post;
$thispost_id = $post->ID;
$posts is an array starting like this:
array(4) { [0]=> object(stdClass)#108 (24) { ["ID"]=> string(3) "821" ... }
[1]=> object(stdClass)#107 (24) { ["ID"]=> string(3) "817" ... }
[2]=> object(stdClass)#110 (24) { ["ID"]=> string(3) "811" ... }
[3]=> object(stdClass)#109 (24) { ["ID"]=> string(3) "807" ... }*/
/* I need to pop the array with $thispost_id out of $posts*/
TIA for any pointers.Daiv Mowbray twincascos Barcelona
wordpress pluginswp-superslider.com
portfolio portfolio.daivmowbray.com
personal blogwww.daivmowbray.com
-
Apr 9, 2009, 18:01 #2
- Join Date
- Aug 2000
- Location
- Philadephia, PA
- Posts
- 20,578
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
PHP Code:foreach ($posts as $key => $obj) {
if ($obj->ID == $thispost_id)
unset($posts[$key]);
}
Try Improvely, your online marketing dashboard.
→ Conversion tracking, click fraud detection, A/B testing and more
-
Apr 9, 2009, 18:19 #3
- Join Date
- May 2003
- Location
- barcelona
- Posts
- 68
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Oh, that was fast,
Thanx you Dan!
Yes that is the how, unset was the trick
Bookmarks