Sory I am a bit tigt on time at the moment (trying to meet the deadline). I changed the function to two functions - one that draws the menu and one that draws the submenu below:
// function to draw menu (top and left)
function draw_menu($script, $items, $div_id) {
// start the list for the menu
$menu = "<ul>";
// loop through the array with menus and submenus
foreach($items as $url => $val) {
$text = $val['text'];
if($script == $url) {
// if the item in the array is the current page, highlight it
$menu .= '<li><a style="font-color:#eb0089" href="#nogo">*** '. $text . ' ***</a></li>';
} else {
// else display it as usual link
$menu .= '<li><a href="' . $url . '">' . $text . '</a></li>';
}
}
// end the list
$menu .= '</ul>';
return $menu;
}
// function to draw submenu below the main menu on left side
function draw_sub_menu($script, $items) {
// find the correct submenu items to draw
foreach($items as $url => $val) {
// if the current page is on the top level (index.php, book.php...)
if($script == $url) {
if(isset($val['submenu']) && !empty($val['submenu'])) {
$submenu = draw_menu($script, $val['submenu']);
return $submenu;
} else {
return '';
}
}
// if the current page is not on the top level, examine each submenu entry
if(isset($val['submenu']) && !empty($val['submenu'])) {
if($script == $val['submenu']['url']) {
$submenu = draw_menu($script, $val['submenu']);
return $submenu;
}
}
}
// if no submenus were drawn return empty string
return '';
}
To use tese functions …