I have some query strings in which I need to remove one variable completely before passing it on. The variable in question is "d" and I do not know what other variables may be in the query string at any given time. I first did a simple replace of $d and the text "d=" and thought that it would be OK. I have had a few problems though as in the example below: ?d=228&f=plastic&h=large&gclid=blahblahblah With my replacements I inadvertently removed part of another variable, destroying it in the process (shown in bold). What function can I use to replace a whole variable (text and value) in one piece so to speak so that I do not have this error in future.
This should be a good start for you. If the value after the d= is always a fixed length, things will be easier for you to code, but if it is a variable length, you will need to calculate the strpos() in order to remove the entire substring and make the replacement. The good news is that the variable d will always either have a ? or a & in front of it followed by an equals sign.