note 88409 deleted from features.http-auth by danbrown
| From: | danbrown@php.net | Date: | Thu, 22 Jan 2009 20:17:30 +0000 |
| Subject: | note 88409 deleted from features.http-auth by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-149674@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
Alright, here's the best generic implementation of "http_digest_parse()" :
// output is array, from input like: a=abc,b="abc" , c = 'abc def'
// "simple" because it can't handle escaped quotes!
function ParseSimpleAssignmentString($input)
{
preg_match_all('@(\w+)\s*=\s*'.
'(?:"(.*?)"|\'(.*?)\'|([^,]*?)\s*(?:,|$))@',
$input, $matches, PREG_SET_ORDER);
$return = array();
foreach($matches as $match)
{
if(!$match[1]) continue;
$data = @$match[2];
if($data=='') $data = @$match[3];
if($data=='') $data = @$match[4];
$return[$match[1]] = $data;
}
return $return;
}