umhh... more efficient... all right
PHP Code:
function buildMenu( $menuSource ) {
$html = "<font class=\"alt\">{$menuSource['page']}</font>";
foreach( $menuSource['links'] as $href => $text ) {
$html .= "<a href=\"$href\">$text</a>";
}
return $html;
}
function getMenuSource( $url ) {
$page = substr( $url, strpos( $url, '/' ) + 1 );
$links = include( 'menu_' . $page );
return array( 'page'=>$page, 'links'=>$links );
}
echo buildMenu( getMenuSource( $url ) );
create one menu file for each page :
PHP Code:
//file menu_page1.php
return array( "link1.php"=>"link1", "link2.php"=>"link2" );
PHP Code:
//file menu_page2.php
return array( "link4.php"=>"link4", "link5.php"=>"link5" );
now you can have as many menus as you like, without touching your code, all you need to do is create another file corresponding to the page it belongs to.
Bookmarks