Edit report at https://bugs.php.net/bug.php?id=60584&edit=1
ID: 60584
User updated by: toms at mindboiler dot lv
Reported by: toms at mindboiler dot lv
-Summary: headers_list should return in a key => value fashion
+Summary: headers_list() should return in a `$key => $value`
fashion
Status: Open
Type: Feature/Change Request
Package: Network related
-Operating System: CentOS 2.6.18
+Operating System: CentOS 2.6.18-274.12.1.el5xen
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Changed the summary a little, OS version.
Previous Comments:
------------------------------------------------------------------------
[2011-12-21 12:34:34] toms at mindboiler dot lv
Description:
------------
The function headers_list() returns the headers in a numeric array fashion,
although, headers are, AFAIK, always in a `Key: Value` fashion, therefore,
associative array would be a better choice.
More on this, header_remove() works by simply passing the key, therefore, in
background, headers have their key representation, I suppose.
I've made an example function that uses this function, for a header lookup, but
ends up in "lots of lines" compared to what could be replaced with one:
https://gist.github.com/1505803
P.S. This is my first file in PHP Bugs section, please guide me if I have given
not enough information.
Test script:
---------------
header('Test-Header: A random result');
var_dump(headers_list());
Expected result:
----------------
array(5) {
["X-Powered-By"]=>
string(23) "PHP/5.3.3"
["Expires"]=>
string(38) "Thu, 19 Nov 1981 08:52:00 GMT"
["Cache-Control"]=>
string(77) "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
["Pragma"]=>
string(16) "no-cache"
["Test-Header"]=>
string(28) "A random result"
}
Actual result:
--------------
array(5) {
[0]=>
string(23) "X-Powered-By: PHP/5.3.3"
[1]=>
string(38) "Expires: Thu, 19 Nov 1981 08:52:00 GMT"
[2]=>
string(77) "Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0"
[3]=>
string(16) "Pragma: no-cache"
[4]=>
string(28) "Test-Header: A random result"
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60584&edit=1