note 112057 deleted from function.http-parse-headers by sobak

From: Date: Sun, 04 Dec 2016 07:22:21 +0000
Subject: note 112057 deleted from function.http-parse-headers by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208064@lists.php.net to get a copy of this message
Note Submitter: g dot kuizinas at anuary dot com ---- <?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" }

« previous php.notes (#208064) next »