Skip to content
Advertisement

Replacing a specific part of a query string PHP

I use $_SERVER['QUERY_STRING'] to get the query sting.

A example would be a=123&b=456&c=789

How could I remove the b value from the query string to obtain a=123&c=789 where b can be any value of any length and is alpha numeric.

Any ideas appreciated, thanks.

Advertisement

Answer

The value is going to be $_GET['b'].

How about:

str_replace('&b='.$_GET['b'], '', $_SERVER['QUERY_STRING']);
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement