beta208
beta208

Reputation: 627

How do I check what's in an array

How do I check what is in the 'menu-highlight' array referenced below, and add to it?

The following is part of an else statement of a PHP function:

 if (in_array('menu-highlight', $item->classes)) :

     $menu_multi[$item->menu_item_parent]->children['highlight'][$item->ID] = $item;

 else :

     $menu_multi[$item->menu_item_parent]->children['standard'][$item->ID] = $item;

 endif;

Upvotes: 0

Views: 155

Answers (1)

taxicala
taxicala

Reputation: 21759

You could use var_dump in order to display (to debug or check) what is in the array:

var_dump($menu_multi[$item->menu_item_parent]->children['highlight']);

or use print_r:

echo "<pre>";
print_r($menu_multi[$item->menu_item_parent]->children['highlight']);
echo "</pre>";

And then if you want to add an item to the array:

$menu_multi[$item->menu_item_parent]->children['highlight'][] = $newItem;

Upvotes: 1

Related Questions