tarun Posted August 24, 2007 Share Posted August 24, 2007 <?php $menu["Home"] = "/index.php"; $submenu["Home"]["About"] = "/about.php"; $menu["Contact Us"] = "/contactus.php"; $submenu["Contact Us"]["Live Chat"] = "/chat/index.php"; $submenu["Contact Us"]["Live Chat"]["Live Help"] = "/chat/connected.php"; $submenu["Contact Us"]["Email"] = "/emailform.php"; $menu["Members"] = "/members/index.php"; $submenu["Members"]["Profile"] = "/members/profiles/index.php"; $submenu["Members"]["Profile"]["View Profile"] = "/members/profiles/viewprofile.php"; $submenu["Members"]["Profile"]["View All Profiles"] = "/members/profiles/viewall.php"; $submenu["Members"]["Profile"]["Edit Profile"] = "/members/profiles/edit.php"; $submenu["Members"]["Check Messages"] = "/members/mail.php"; $submenu["Members"]["Send A Message"] = "/members/send.php"; $submenu["Members"]["Edit Profile"] = "/members/editprofile.php"; ?> Well... Thats My Multi Dimensional Array How Would I Go About Making A Breadcrumb Menu From It In Case You Didn't No A Breadcrumb Menus Are Like This: [iurl=#]Members[/iurl] / [iurl=#]Profile[/iurl] / [iurl=#]Edit Profile[/iurl] Quote Link to comment https://forums.phpfreaks.com/topic/66534-solved-multidimensional-array-breadcrumb-menu/ Share on other sites More sharing options...
lemmin Posted August 24, 2007 Share Posted August 24, 2007 The best way of doing this with an array would be to keep track of exactly where the user is in a session. That way you don't have to search the array for what page the user is on and it will work if the page is directed to from multiple locations. Quote Link to comment https://forums.phpfreaks.com/topic/66534-solved-multidimensional-array-breadcrumb-menu/#findComment-333197 Share on other sites More sharing options...
GingerRobot Posted August 24, 2007 Share Posted August 24, 2007 Well, with the array set up as you have it, you'll run into problems. You can't have an element of an array as BOTH a string and an array. For instance, you have $submenu["Contact Us"]["Live Chat"] equal to the string "/chat/index.php" and it is also an array. If you were to modify your $submenu array so that it only ever has two dimensions, the first being the parent node, the second the child, you can write a recursive function similar to: <?php function menu($menu,$index='Parent'){ foreach($menu[$index] as $k => $v){ echo "<li><a href='$v'>$k</a></li>"; if(is_array($menu[$k])){ echo '<ul>'; menu($menu,$k); echo '</ul>'; } } } $menu = array(); $menu["Parent"]["Home"] = "/index.php"; $menu["Parent"]["Contact Us"] = "/contactus.php"; $menu["Parent"]["Members"] = "/members/index.php"; $menu["Home"]["About"] = "/about.php"; $menu["Contact Us"]["Live Chat"] = "/chat/index.php"; $menu["Live Chat"]["Live Help"] = "/chat/connected.php"; $menu["Contact Us"]["Email"] = "/emailform.php"; echo '<ul>'; menu($menu); echo '</ul>'; ?> Give that a shot. P.S. 1000th post EDIT: Reposted with a neater function. Quote Link to comment https://forums.phpfreaks.com/topic/66534-solved-multidimensional-array-breadcrumb-menu/#findComment-333210 Share on other sites More sharing options...
tarun Posted August 24, 2007 Author Share Posted August 24, 2007 Thanks Alot (Both Of You ) And Congratz GingerRobot Its An Honor Quote Link to comment https://forums.phpfreaks.com/topic/66534-solved-multidimensional-array-breadcrumb-menu/#findComment-333247 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.