brian wilson
brian wilson

Reputation: 495

PHP get query string from a string

I have a string with a URL

$string = "http://www.yahoo.com/foo.php?bar=201";

all i want is the query string without everything else.

obviously cant user query_string, help appreciated.

Upvotes: 0

Views: 69

Answers (1)

Dan Grossman
Dan Grossman

Reputation: 52372

$parts = parse_url($string);
echo $parts['query'];

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

Upvotes: 5

Related Questions