@bluewalrus and @james348: Thanks for reply i have tried both of your code, but doesn't work,
this is my code:
PHP Code:
<?
function menu_top(){
$domain = "http://www.mysite.ext"; //can be mysite.com, mysite.us, mysite.co.id, mysite.web.id, and so on
$menu = array(
'Home' => $domain,
'People' => $domain.'/people/',
'News' => $domain.'/news/',
'Blog' => $domain.'/blog/'
);
$current_page = $domain.$_SERVER['PHP_SELF'];
//this current page always return something like http://www.mysite.ext/index.php/mypage/
//sometimes return http://www.mysite.ext/index.php
//
//home link, in menu shows http://www.mysite.ext/ , but in current_page return http://www.mysite.ext/index.php
//people link, in menu show http://www.mysite.ext/people/, but in current_page return http://www.mysite.ext/incex.php/people/
//and the other link are too
//
/*
so, i want a regex to remove index.php from $current_page,
like:
http://mysite.com/
http://mysite.com/people/
not like:
http://mysite.com/
http://mysite.com//people/
not like:
http://mysite.com
http://mysite.com/people/
*/
$ret ='<ul>';
foreach($menu as $link_text => $link_url){
if( $current_page == $link_url)
$ret .='<li class="link_active">'.$link_text.'</li>';
else
$ret .='<li><a href="'.$link_url.'">'.$link_text.'</a></li>';
}
$ret .='</ul>';
return $ret;
}
?>
Bookmarks