Change single variable value in querystring [closed]
Use
parse_url()
to extract the query string from the URLparse_str()
to split the query string into an arrayarray_merge()
to add a new array"b" => 5
http_build_query()
to re-build a query stringThe remaining parts from the first step (protocol, host, path...) to re-build the full URL or - if you have the
HTTP
pecl extension - ahttp_build_url()
withHTTP_URL_JOIN_QUERY
will alleviate much of the work.