Here is what I got http://codepad.org/iDoXXsLX
Have an array like this
Array ( [0] => Array ( [NumberRenamed] => 17 [TopicName] => Products [UpperLevelNumberRenamed] => 0 ) [17] => Array ( [0] => Array ( [1] => Array ( [NumberRenamed] => 18 [TopicName] => Computers [UpperLevelNumberRenamed] => 17 ) ) ) [18] => Array ( [0] => Array ( [2] => Array ( [NumberRenamed] => 16 [TopicName] => Laptops [UpperLevelNumberRenamed] => 18 ) ) ) [16] => Array ( [0] => Array ( [4] => Array ( [NumberRenamed] => 8 [TopicName] => Dell [UpperLevelNumberRenamed] => 16 ) ) ) )
Products top-level item, the first Computers sublayer element, the next sublayer is Laptops , then again the next Dell sublayer
For each element of the universe, UpperLevelNumberRenamed == to the nearest top level NumberRenamed .
Want to get this result
Products Computers Laptops Dell Acer Desktops Home
Tried this
foreach( $main_topics as $k_main_topics => $v_main_topics ){ if( isset($v_main_topics['UpperLevelNumberRenamed']) and $v_main_topics['UpperLevelNumberRenamed'] == 0 ){ //print only top level topics echo $v_main_topics['TopicName']. '<br/>'; } else{//if not top level topic foreach( $v_main_topics[0] as $k_v_main_topics_0 => $v_v_main_topics_0 ){ echo $v_v_main_topics_0['TopicName']. '<br/>'; }//foreach( $v_main_topics[0] as $k_v_main_topics_0 => $v_v_main_topics_0 ) }//else{ }//foreach( $main_topics as $k_main_topics => $v_main_topics )
But get it
Products Home Computers Laptops Desktops Dell Acer
Something is wrong, but I canβt understand. Please advice what needs to be fixed / changed in the code
Trying another way
The starting array is a one-dimensional array. Trying to get navigation navigation from one size.
Here is what I did http://codepad.org/OLtxyL4X
source share