I have a page that lists items by numerous parameters, i.e. variables with values.
listitems.php?color=green&size=small&cat=pants&pagenum=1 etc.
To enable list editing, I have an edit = 1 parameter, which is added to the above sequence:
listitems.php?color=green&size=small&cat=pants&pagenum=1&edit=1
So far so good.
When the user has finished editing, I have a link that exits the editing mode. I want this link to indicate the entire sequence of requests — whatever it is, since it depends on the user's choice — other than deleting edit = 1.
When I had only a few variables, I simply listed them manually by reference, but now that there is more, I would like to be able to programmatically just delete edit = 1.
Should I do some kind of search for edit = 1, and then just replace it with nothing?
$qs = str_replace("&edit=1, "", $_SERVER['QUERY_STRING']); <a href='{$_SERVER['PHP_SELF']}?{$qs}'>return</a>;
Or, what would be the cleanest, most error-free way to do it.
Note. I have a similar situation when switching from page to page where I would like to take out pagenum and replace it with another. There, since pagenum is changing, I can't just look for pagenum = 1, but you have to look for pagenum =$pagenum , if that matters.
Thanks.