i have this function that should remove part of a query string:
if(!function_exists("remove_querystring_var")) {
function remove_querystring_var($url, $key) {
$url = preg_replace('/(.*)(?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&');
$url = substr($url, 0, -1);
return ($url);
}
}
i have ahref links like:
<a href="link.php?<?php echo $_SERVER["QUERY_STRING"]; ?>">link</a>
but i need to be able to remove ?pagenum=X (X = a page number)
parse_str()+http_build_query()remove_querystring_varfunction work? Not work? What's the question here?if(!function_exists("remove_querystring_var")) {looks like fixing consequences not the roots.