Parsing URL query in PHP [duplicate]

You can take the second step and parse the query string using parse_str.

$url="www.domain.org?x=1&y=2&z=3";
$url_parts = parse_url($url);
parse_str($url_parts['query'], $query_parts);
var_dump($query_parts);

I assumed you meant the query string instead of the fragment because there isn’t a standard pattern for fragments.

Leave a Comment