Here's a starting point for ya.
PHP Code:
<?php
$myarr = array(
'1' => array(
'1.1' => array(
'1.1.1'
,'1.1.2'
)
,'1.2' => array(
'1.2.1'
,'1.2.2'
)
)
,'2' => array(
'2.1' => array(
'2.1.1'
)
)
,'3' => array(
'3.1' => array(
'3.1.1'
)
)
);
$curpage = '2';
$curpage_arr = $myarr[$curpage];
unset($myarr[$curpage]);
echo "<pre>";
print_r($curpage_arr);
print_r(array_reverse($myarr, TRUE));
echo "</pre>";
There. I've done about half the work for you by showing you array_reverse(). The part about $curpage is half-baked, as I havent wrote the function to recurse the array searching for the the array key you provide as the $curpage. I think you can finish the rest (its not that difficult). Also, this structure does not make much sense to me logically. If I was navigating your site I'd probably leave. Have you considered an alternate method of navigation? Perhaps you use a drilldown navigation instead of a tree (you have a main menu and a sub menu, depending on the section you are in)?
Bookmarks