BODEKA Posted December 20, 2007 Share Posted December 20, 2007 $menu_arr = array( 'a' => array('name'=>'A', 'path'=>'a.php'), 'b' => array('name'=>'B', 'path'=>'b.php', 'submenu'=> array( 'b_a' => array('name'=>'B_A', 'path'=>'b_a.php'), 'b_b' => array('name'=>'B_B', 'path'=>'b_b.php','submenu'=> array( 'x' => array('name'=>'X', 'path'=>'x.php'), 'y' => array('name'=>'Y', 'path'=>'y.php'))), 'b_c' => array('name'=>'B_C', 'path'=>'b_c.php'))), 'c' => array('name'=>'C', 'path'=>'c.php') ); function get_path($arr, $filename, $retval = '') { foreach($arr as $key=>$value) { $retval .= $value['name'].'&'.$value['path'].' | '; if($key==$filename) { return $retval; } if( isset($value['submenu']) ) { get_path($value['submenu'], $filename, $retval); } } // end foreach } I have been struggling to find a way to get the the path as follows: For example echo get_path($menu_arr, 'b_c' ); should spit out: B&b.php|B_C&b_c.php or echo get_path($menu_arr, 'Y' ); B&b.php|B_B&b_b.php|Y&y.php Link to comment https://forums.phpfreaks.com/topic/82531-menu-array/ Share on other sites More sharing options...
BODEKA Posted December 23, 2007 Author Share Posted December 23, 2007 Nobody have any idea? Link to comment https://forums.phpfreaks.com/topic/82531-menu-array/#findComment-421737 Share on other sites More sharing options...
PHP_PhREEEk Posted December 23, 2007 Share Posted December 23, 2007 Too many A's, B's, B_C's, Y's, X's and other stuff to track, so I passed.. sorry... maybe someone else will sort through all of it. PhREEEk Link to comment https://forums.phpfreaks.com/topic/82531-menu-array/#findComment-421752 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.