php - Disable menu option for current page with preg_replace -
i'm trying disable link current page in drop down menu using preg_replace. specifically, i'm attempting append class name , "disabled" attribute menu option points current page (the page name in query string).
so far can load menu, preg_replace doesn't (preg_replace confusing me @ times).
<?php $menu = file_get_contents("menu.php"); $q_param = $_server['query_string']; $menu = preg_replace("|<option value=\"routemap.php?$q_param\"></option>|u", "<option value=\"routemap.php?$q_param\" class=\"red\" disabled=\"disabled\">$1</option>", $menu); echo $menu; ?>
edit: fixed with:
<?php $menu = file_get_contents("menu.php"); $param = $_server['query_string']; $menu = preg_replace("/$param/", "$param\" class=\"red\" disabled=\"disabled", $menu); echo $menu; ?>
it problem beginning , end markers search pattern (i think).
Comments
Post a Comment