How do i rearrange PHP Array Data?

Tyler

New member
I have an array called from the function get_menu()... I am printing it using this:

foreach ( get_menu() as $p_menu => $p_data) {

foreach($p_data as $item => $i_data) {
//print_r($i_data);
echo "<a href=\"{$i_data['url']}\"><br>";
echo "{$i_data['name']}</a> ";
}
}

This formula prints the menu below. Their are TWO other items in the array $i_data['kei'] AND $i_data['parent'].

I need these items to be used in arranging the menu. To look the way the second menu below looks.

Basically where KEI==PARENT, insert that item under it's parent.

=============
The above menu prints this menu

-Home
-Page1
-Page2
-Page3
-Pagesub 1
-Pagesub 1.5
-Pagesub 3
-Pagesub 3.5


==========
I need the menu to print like this

-Home
-Page1
----Pagesub 1
----Pagesub 1.5
-Page2
-Page3
----Pagesub 3
----Pagesub 3.5

==============
 
Back
Top