note 12413 deleted from function.array-splice by jimw
| From: | jimw@php.net | Date: | Fri, 11 Jan 2002 21:50:00 +0000 |
| Subject: | note 12413 deleted from function.array-splice by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-24712@lists.php.net to get a copy of this message | ||
i wanted to handle a query-string that way, that a certain variable can be removed from the
query-string, while keeping the rest of it. e.g. you can use this to integrate an application into
others ( proper API):
/**
* Proper handling of query-string to make this script
* application-independent and easy-integratable.
*
* @param $index, $addon
*/
function url($index="page", $addon="" ) {
global $HTTP_GET_VARS;
foreach($HTTP_GET_VARS as $key => $val ) {
$q[$key] = $val;
}
if(is_array($q )) {
// remove $index element from the list
unset($q[$index]);
// create new query-string
foreach($q as $key => $val ) {
$str .= "$key=$val&";
}
return $str . $addon;
} else {
return $addon;
}
}