Page 1 of 1

looking for a function to parse URL parameters

Posted: Sun Sep 12, 2004 3:47 am
by jasongr
Hello

I was wondering if anyone knows if there is a PHP function that takes as input a URL string, parses it and returns an array of all the parameters in the string.

Here is an example:

"text.html?a=1&b=2&c=3"

output would be:
array('a' => 1, 'b' => 2, 'c' => 3)

regards

Posted: Sun Sep 12, 2004 4:11 am
by mudkicker
$_SERVER['QUERY_STRING'] would be may be helpful...

Posted: Sun Sep 12, 2004 4:17 am
by jasongr
I have found parse_str() to be useful

Posted: Sun Sep 12, 2004 8:16 am
by kettle_drum
Or simply:

Code: Select all

print_r($_GET);

Posted: Sun Sep 12, 2004 8:34 am
by jasongr
Actually I was looking for a function that will parse the string into an array I can later manipulate, not just to see it

Posted: Sun Sep 12, 2004 10:21 am
by feyd
you can play with the $_GET array all you want.. it's writable.