OMG! How retarded am I. Duh. of course... For some reason I thought you could use the & reference because it was a "pointer" to the actual object menuItem::removeMenuItems($navArray['dart'], array('Login', 'Lost Password')); public static final function removeMenuItems(&$menuItems, $removeArray) { foreach($menuItems as $key => $value) if (is_array($value->children)) menuItem::removeMenuItems($value->children, $removeArray); elseif (in_array($value->menu, $removeArray)) unset($menuItems[$key]); } -----Original Message----- From: Chris <dmagick@xxxxxxxxx> To: Daevid Vincent <daevid@xxxxxxxxxx> Cc: php-general@xxxxxxxxxxxxx, Shawn McKenzie <nospam@xxxxxxxxxxxxx> Subject: Re: Re: How do I remove an array element from within a recursive function? Date: Fri, 27 Feb 2009 13:47:38 +1100 Daevid Vincent wrote: > I tried that and it still doesn't work. I even tried this hardcore > "test": > > public static final function removeMenuItems(&$menuItems, $removeArray) > { > foreach($menuItems as &$value) > { > unset($value); > } > } You don't unset the value, you unset the key. <?php $items = array('menu1', 'menu2', 'menu3'); echo "Before:\n"; print_r($items); foreach ($items as $_menuKey => $value) { if ($value == 'menu2') { unset($items[$_menuKey]); } } echo "After:\n"; print_r($items); $ php test.php Before: Array ( [0] => menu1 [1] => menu2 [2] => menu3 ) After: Array ( [0] => menu1 [2] => menu3 )