I am using the answer here https://stackoverflow.com/a/27689796/3842368 to strip off several parameters from a url. I thought it was working, until today when I found out that unset() wasn't working if I defined multiple parameters.
My PHP code is:
$url = $_SERVER["REQUEST_URI"];
$x = $url;
$parsed = parse_url($x);
$query = $parsed['query'];
parse_str($query, $params);
unset($params['qdef, qval1']);
$string = http_build_query($params);
$params is producing the following array, using print_r:
Array ( [use_url] => on [zipcode] => Axminster, Devon EX13 5RZ [categories] => Array ( [0] => 2 ) [radius] => 0 [checkboxnational] => 1 [submit] => loading results... [yesq] => y [qdef] => 2 [qval1] => 100.00 [qval2] => 525.00 [seasoning] => 1 [slider-value1] => 0 [slider-value2] => 70 [resultbar] => 25 [sortbar] => distance [lat] => 50.77643440000001 [lng] => -2.9810417 [swlat] => 50.7773526197085 [swlng] => -2.9814507999999478 [nelat] => 50.7800505802915 [nelng] => -2.9749947000000247 [outcode] => EX13 ) 1
so the problem I have is that if I write unset($params['qdef']);
then qdef is stripped from the url, but if I write unset($params['qdef, qval1']);
then nothing is stripped. I've tried separating them with a comma, enclosing each parameter in '[]', nothing works. I've tried many ways of defining the parameters in the unset() command but nothing works.
Any thoughts?