note 78601 deleted from function.http-parse-headers by felipe
| From: | felipe@php.net | Date: | Sun, 16 Dec 2007 12:10:57 +0000 |
| Subject: | note 78601 deleted from function.http-parse-headers by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133683@lists.php.net to get a copy of this message | ||
Note Submitter: web
Reason: 1
----
small addition for
user at example dot net
<?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]]))
{
array_push($retVal[$match[1]], $match[2]);
}
else
{
$retVal[$match[1]] = array($retVal[$match[1]], $match[2]);
}
} else {
$retVal[$match[1]] = trim($match[2]);
}
}
}
return $retVal;
}
?>