note 86557 deleted from function.urldecode by danbrown
| From: | danbrown@php.net | Date: | Thu, 23 Oct 2008 16:43:37 +0000 |
| Subject: | note 86557 deleted from function.urldecode by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145661@lists.php.net to get a copy of this message | ||
Note Submitter: cheshire137 at gmail dot com
Reason: in docs
----
Given a URL like http://mysite.com/?name=Jim this will
return an array like this:
array("name" => "Jim");
function extract_keys($url) {
$keys_start = strpos($url, '?') + 1;
$url = substr($url, $keys_start);
$keys = array();
$pair = explode('&', $url);
foreach ($pair as $key_value) {
list($key, $value) = split('=', $key_value);
$key = htmlspecialchars(urldecode($key));
$value = htmlspecialchars(urldecode($value));
$keys[$key] = $value;
}
return $keys;
}