Skip to main content
Code Review

Return to Revisions

2 of 3
added 339 characters in body

There are built-in functions for this purpose, in PHP.


First you split the different part of the url : $parsedUrl = parse_url($url);

Here is the part you're looking for : $queryPart = $parsedUrl["query"];

You can split this query in parts with parse_str($queryPart, $_QUERY);

And Voilà ! var_dump($_QUERY);

You now can remove what you want from the $_QUERY Array. ( unset($_QUERY['parameter']); )

And construct the Query String back : $queryPart = http_build_query($_QUERY);

Put the query back in the $parsed_url : $parsedUrl["query"] = $_QUERY;

And finally reconstruct the url : http_build_url('', $parsedUrl["query"] );


Here you go : http://php.net/manual/en/function.parse-url.php

default

AltStyle によって変換されたページ (->オリジナル) /