I have an array like this and I simply need to recurse over it and find
a matching "menu" item to remove:

array(3) {

 ["dart"]=>
  array(10) {
    [0]=>
    object(menuItem)#4 (9) {
      ["menu"]=>
      string(7) "My DART"
      ["name"]=>
      string(7) "My DART"
      ["title"]=>
      string(39) "Data Analasys & Reliability Tracker"
      ["employee_only"]=>
      bool(false)
      ["page"]=>
      NULL
      ["children"]=>
      NULL
      ["parent"]=>
      NULL
      ["current"]=>
      bool(false)
      ["array_key"]=>
      string(4) "dart"
    }
    [1]=>
    object(menuItem)#5 (9) {
      ["menu"]=>
      string(5) "Login"
      ["name"]=>
      string(5) "Login"
      ["title"]=>
      string(5) "Login"
      ["employee_only"]=>
      bool(false)
      ["page"]=>
      string(9) "login.php"
      ["children"]=>
      NULL
      ["parent"]=>
      NULL
      ["current"]=>
      bool(false)
      ["array_key"]=>
      string(4) "dart"
    }
    [2]=>
    object(menuItem)#6 (9) {
      ["menu"]=>
      string(13) "Lost Password"
      ["name"]=>
      string(13) "Lost Password"
      ["title"]=>
      string(13) "Lost Password"
      ["employee_only"]=>
      bool(false)
      ["page"]=>
      string(12) "forgotpw.php"
      ["children"]=>
      NULL
      ["parent"]=>
      NULL
      ["current"]=>
      bool(false)
      ["array_key"]=>
      string(4) "dart"
    }
...

I'm trying to remove ["menu"] == 'Login' from the array, but despite "finding" 
the element, it never removes.
isn't that what the & reference stuff is for?

menuItem::removeMenuItems($navArray['dart'], array('Login', 'Lost Password'));


        public static final function removeMenuItems(&$menuItems, $removeArray)
        {
                foreach($menuItems as $value)
                {
                        if (is_array($value->children))
                                menuItem::removeMenuItems(&$value->children, 
$removeArray);
                        else
                        {
                                //echo "*** CHECKING ".$value->menu." against 
".implode(',',$removeArray)." ***";
                                if (in_array($value->menu, $removeArray))
                                {
                                        //echo "*** REMOVING ".$value->menu." 
***";
                                        unset($value);
                                }
                        }
                }
        }

Reply via email to