note 78713 added to function.headers-list

From: Date: Wed, 24 Oct 2007 16:57:57 +0000
Subject: note 78713 added to function.headers-list
Groups: php.notes 
Request: Send a blank email to php-notes+get-131692@lists.php.net to get a copy of this message
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" } ---- Server IP: 69.147.83.197 Probable Submitter: 70.252.92.160 ---- Manual Page -- http://www.php.net/manual/en/function.headers-list.php Edit -- https://master.php.net/note/edit/78713 Del: integrated -- https://master.php.net/note/delete/78713/integrated Del: useless -- https://master.php.net/note/delete/78713/useless Del: bad code -- https://master.php.net/note/delete/78713/bad+code Del: spam -- https://master.php.net/note/delete/78713/spam Del: non-english -- https://master.php.net/note/delete/78713/non-english Del: in docs -- https://master.php.net/note/delete/78713/in+docs Del: other reasons-- https://master.php.net/note/delete/78713 Reject -- https://master.php.net/note/reject/78713 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#131692) next »