note 108896 deleted from reserved.variables.get by danbrown
| From: | danbrown@php.net | Date: | Sat, 02 Jun 2012 18:51:30 +0000 |
| Subject: | note 108896 deleted from reserved.variables.get by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-188371@lists.php.net to get a copy of this message | ||
Note Submitter: grantwparks at gmail dot com
----
A smaller version of getUrlWithout using http_build_query, parse_str and array functions. And
changing the function to accept a querystring argument; IMO it would be better to separate handling
the rest of the url.
<?php
function getUrlWithout ($querystring, $getNames) {
parse_str ($querystring, $arrQS);
return http_build_query (array_diff_key ($arrQS, array_flip ($getNames)));
}
$querystring = "getVar1=Something&getVar2=10&getVar3=ok";
echo getUrlWithout($querystring, array("getVar1","getVar3"));
?>
returns getVar2=10