How to make an array of menu items in PHP?
I have the following array in PHP for my menu ite开发者_高级运维ms:
$items = array('Home' => 'URL1', 'Info' => 'URL1', 'Contact' => 'URL3');
Now I want to be able to add an extra value to one index at a time, indicating that it is a selected tab.
How would I do that in a fancy way?
you could use a multi dimensional array like so
$array['home']['url'] = 'url';
$array['home']['selected'] = true;
then if a particular url is selected you just set its selected value to true, you could also add other properties to the nav as well then for instance you could add a hidden value
$array['home']['hidden'] = true;
------- edit
apologies for the terrible formatting im doing this off my mobile phone
You could make an extra variable for it:
$items = array('Home' => 'URL1', 'Info' => 'URL1', 'Contact' => 'URL3');
$active_item='Info';
精彩评论