note 112057 added to function.http-parse-headers
| From: | g dot kuizinas at anuary dot com | Date: | Sat, 27 Apr 2013 08:20:49 +0000 |
| Subject: | note 112057 added to function.http-parse-headers | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-194642@lists.php.net to get a copy of this message | ||
<?php
$headers = "HTTP/1.1 302 Found
Server: nginx
Date: Sat, 27 Apr 2013 08:07:57 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 976
Connection: keep-alive
X-Frame-Options: sameorigin
X-Runtime: 443
Status: 302
Cache-Control: max-age=86400
Expires: Sun, 28 Apr 2013 08:07:56 GMT
Vary: Accept-Encoding,User-Agent
Strict-Transport-Security: max-age=3600 ; includeSubDomains";
if (!function_exists('http_parse_headers')) {
function http_parse_headers ($raw_headers) {
$headers = [];
foreach (explode("\n", $raw_headers) as $i => $h) {
$h = explode(':', $h, 2);
if (isset($h[1])) {
$headers[$h[0]] = trim($h[1]);
}
}
return $headers;
}
}
var_dump(http_parse_headers($headers));
?>
array(12) {
["Server"]=>
string(5) "nginx"
["Date"]=>
string(29) "Sat, 27 Apr 2013 08:07:57 GMT"
["Content-Type"]=>
string(24) "text/html; charset=utf-8"
["Content-Length"]=>
string(3) "976"
["Connection"]=>
string(10) "keep-alive"
["X-Frame-Options"]=>
string(10) "sameorigin"
["X-Runtime"]=>
string(3) "443"
["Status"]=>
string(3) "302"
["Cache-Control"]=>
string(13) "max-age=86400"
["Expires"]=>
string(29) "Sun, 28 Apr 2013 08:07:56 GMT"
["Vary"]=>
string(26) "Accept-Encoding,User-Agent"
["Strict-Transport-Security"]=>
string(32) "max-age=3600 ; includeSubDomains"
}
----
Server IP: 69.147.83.199
Probable Submitter: 84.233.227.50
----
Manual Page -- http://php.net/manual/en/function.http-parse-headers.php
Edit -- https://master.php.net/note/edit/112057
Del: integrated -- https://master.php.net/note/delete/112057/integrated
Del: useless -- https://master.php.net/note/delete/112057/useless
Del: bad code -- https://master.php.net/note/delete/112057/bad+code
Del: spam -- https://master.php.net/note/delete/112057/spam
Del: non-english -- https://master.php.net/note/delete/112057/non-english
Del: in docs -- https://master.php.net/note/delete/112057/in+docs
Del: other reasons-- https://master.php.net/note/delete/112057
Reject -- https://master.php.net/note/reject/112057
Search -- https://master.php.net/manage/user-notes.php