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

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -