note 78713 deleted from function.headers-list by felipe
| From: | felipe@php.net | Date: | Sun, 16 Dec 2007 11:42:39 +0000 |
| Subject: | note 78713 deleted from function.headers-list by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133670@lists.php.net to get a copy of this message | ||
Note Submitter: ejsexton82 at gmail dot com
Reason: 5
----
I don't know if there is already a function for this or not, but I wrote one anyways.
<?PHP
function headers_array() {
$return = array();
$headers = headers_list();
foreach($headers as $header) {
if(strpos($header,':') === false) $return[0] = $header;
else {
$parsed = explode(':',$header,2);
$return[$parsed[0]] = trim($parsed[1]);
}
}
return $return;
}
var_dump(headers_array());
?>
yeilds:
array(5) {
["X-Powered-By"]=>
string(9) "PHP/5.2.4"
["Expires"]=>
string(29) "Thu, 19 Nov 1981 08:52:00 GMT"
["Cache-Control"]=>
string(62) "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
["Pragma"]=>
string(8) "no-cache"
["Content-type"]=>
string(9) "text/html"
}