note 31440 deleted from reserved.variables by sniper
| From: | sniper@php.net | Date: | Tue, 21 Oct 2003 19:43:33 +0000 |
| Subject: | note 31440 deleted from reserved.variables by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-59068@lists.php.net to get a copy of this message | ||
Note Submitter: dune2@online.bg
----
A simple function to retrieve and delete HTTP get params so that you can replace them.
//Input:
//String or Array containing http get variable name(s)
For example if you have
www.mysite.com?pos=1&item=2
get_url_params();
will return
?pos=1&item=2
get_url_params("pos");
will return
?item=2
get_url_params(array("pos","item"));
will return
?
function get_url_params($exclude=false) {
reset($_GET);
while (list($k, $v) = each($_GET)) {
if (is_array($exclude)) {
foreach($exclude as $x)
$get_params_excluded[$i++].=($k==$x)?'&'.$k.'='.$v:'';
}
$get_params.=($k!=$exclude)?'&'.$k.'='.$v:'';
}
$get_params=str_replace($get_params_excluded, '', $get_params);
if(!empty($get_params))
$get_params='?'.substr($get_params, 1);
else
$get_params='?';
return $get_params;
}