note 53215 deleted from faq.html by felipe

From: Date: Tue, 22 Apr 2008 01:08:06 +0000
Subject: note 53215 deleted from faq.html by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-138638@lists.php.net to get a copy of this message
Note Submitter: lyricnz ---- I'm surprised this is not a language function, but PHP should be able to deal with repeated values in parsing a HTTP URL. (eg: ?foo=1&foo=2). In the meantime you can use something like: function getQueryBits($query,$getkey) { $results = array(); foreach (split('&',$query) as $bit) { @list($key,$value) = split('=',$bit); if ($key==$getkey && $value!=NULL) $results[] = urldecode($value); } return $results; } then you can invoke this method thusly: getQueryBits($_SERVER['QUERY_STRING'], 'foo'); For example, on ?foo=1&foo=2&wibble&foo this will return an array with two elements, "1" and "2"

« previous php.notes (#138638) next »