note 111226 added to function.http-parse-headers
| From: | Anonymous | Date: | Mon, 28 Jan 2013 22:23:12 +0000 |
| Subject: | note 111226 added to function.http-parse-headers | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-193417@lists.php.net to get a copy of this message | ||
This one works even better:
<?php
function http_parse_headers( $header )
{
$retVal = array();
$fields = explode("\r\n", preg_replace('/\x0D\x0A[\x09\x20]+/', '
', $header));
foreach( $fields as $field ) {
if( preg_match('/([^:]+): (.+)/m', $field, $match) ) {
$match[1] = preg_replace('/(?<=^|[\x09\x20\x2D])./e',
'strtoupper("\0")', strtolower(trim($match[1])));
if( isset($retVal[$match[1]]) ) {
if (!is_array($retVal[$match[1]])) {
$retVal[$match[1]] = array($retVal[$match[1]]);
}
$retVal[$match[1]][] = $match[2];
} else {
$retVal[$match[1]] = trim($match[2]);
}
}
}
return $retVal;
}
?>
----
Server IP: 69.147.83.199
Probable Submitter: 86.26.168.13
----
Manual Page -- http://php.net/manual/en/function.http-parse-headers.php
Edit -- https://master.php.net/note/edit/111226
Del: integrated -- https://master.php.net/note/delete/111226/integrated
Del: useless -- https://master.php.net/note/delete/111226/useless
Del: bad code -- https://master.php.net/note/delete/111226/bad+code
Del: spam -- https://master.php.net/note/delete/111226/spam
Del: non-english -- https://master.php.net/note/delete/111226/non-english
Del: in docs -- https://master.php.net/note/delete/111226/in+docs
Del: other reasons-- https://master.php.net/note/delete/111226
Reject -- https://master.php.net/note/reject/111226
Search -- https://master.php.net/manage/user-notes.php