Skip to content

Instantly share code, notes, and snippets.

@EricYue2012
Created November 14, 2013 03:44
Show Gist options
  • Save EricYue2012/7460981 to your computer and use it in GitHub Desktop.
Save EricYue2012/7460981 to your computer and use it in GitHub Desktop.
Remove specified key from url question string
function remove_url_key($key){
$base_uri = $_SERVER['QUERY_STRING'];
$_new_uri = array();
if(!isset($_GET[$key]))
{
$q_string = $base_uri;
}else
{
foreach($_GET as $uri=>$val)
{
if ($uri != $key)
{
$_new_uri[$uri] = $val;
}
}
$q_string = http_build_query($_new_uri);
}
return $q_string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment