Possible Duplicate:
How to grab URL parameters using PHP?
I was wondering how can I store each url parameter each in there own new variable when I don't know how deep the url parameters are?
Here is an example of a URL value.
http://www.localhost.com/topics/index.php?cat=3&sub1=sub-1&sub2=sub-2&sub3=sub-3&sub4=sub-4
Here is my PHP script.
$url = $_SERVER['QUERY_STRING'];
$query = array();
if(!empty($url)){
foreach(explode('&', $url) as $part){
list($key, $value) = explode('=', $part, 2);
$query[$key] = $value;
}
}