note 65957 deleted from reserved.variables by philip

From: Date: Wed, 21 Feb 2007 15:52:49 +0000
Subject: note 65957 deleted from reserved.variables by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-123640@lists.php.net to get a copy of this message
Note Submitter: jwl007 ---- Here's a quick function for replacing values within a query string. I use this quite a bit for ordering a list obtained from a database. e.g. If I want a link to order the list by firstname, I would use: <a href=".replaceQueryString('orderby',$firstname).">first</a>. If I want a link to order by last name, I would use: <a href=".replaceQueryString('orderby',$lastname).">last</a>. //$var = global query variable //$val = new value for global query variable function replaceQueryString($var,$val){ global $HTTP_SERVER_VARS; $query_string = $HTTP_SERVER_VARS["QUERY_STRING"]; return preg_replace("/$var=[\\d\\w]*/","$var=$val",$query_string); } Hope this helps someone..

« previous php.notes (#123640) next »