The Little Guy Posted September 16, 2008 Share Posted September 16, 2008 My code is doing a few things wrong: 1. It is misspelling "Visitor Information" as "Bisitor Information" 2. It is not making my sub array(s). Current Code: $links['create'] = 'New Project'; $links['settings'] = 'Settings'; $links['stats?page=visitor'] = 'Visitor Information'; $links['stats?page=visitor']['&sub=browser'] = 'Browser Information'; $links['stats?page=traffic'] = 'Traffic Information'; echo '<div style="line-height:20px;">'; foreach($links as $link => $text){ echo '<div><a href="'.$link.'">'.$text.'</a></div>'; if(is_array($link)){ foreach($link as $l => $t){ echo $link.$l.'<br>'; } } } echo '</div>'; Output: New Project Settings Bisitor Information Traffic Information Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted September 16, 2008 Share Posted September 16, 2008 You can't make a sub-array out of a string. See here: $links['stats?page=visitor'] = 'Visitor Information'; You are making the element stats?page=visitor a string, by assigning it the value of 'Visitor Information'. Then here: $links['stats?page=visitor']['&sub=browser'] = 'Browser Information'; You are trying to assign an array onto the string, which does not work. I think you may need to re-think the idea. This should work: $links['create'] = 'New Project'; $links['settings'] = 'Settings'; $links['stats?page=visitor'] = array('Visitor Information'); $links['stats?page=visitor']['&sub=browser'] = 'Browser Information'; $links['stats?page=traffic'] = 'Traffic Information'; echo '<div style="line-height:20px;">'; foreach($links as $link => $text){ if(is_array($text)){ foreach($text as $l => $t){ echo '<div><a href="'.$link.($l == "0" ? "" : $l).'">'.$t.'</a></div>'; } }else{ echo '<div><a href="'.$link.'">'.$text.'</a></div>'; } } echo '</div>'; I did a bit of re-ordering and changed a few things, not sure if that's how you want it though. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted September 16, 2008 Author Share Posted September 16, 2008 OK, here is what I would like: The outer array info, should is the main links, and the inner array info are sub menus, In the above, Visitor Information, and Traffic Information are "main" menu items, and everything else is a sub menu item. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.