|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2000-06-09 15:52 UTC] andrei at cvs dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 04:00:01 2025 UTC |
If the first element of an array has a numeric index, PHP treats the whole array as numerically indexed array, even if the subsequent elements of the array have a string key. session_start(); printf('Current session data is: <pre>%s</pre>', htmlspecialchars(session_encode())); var_dump($foo); $foo = array (0 => true, "foo" => "stringvalue"); session_register("foo"); print('<p>'); var_dump($foo); This code leads to: Current session data is: <pre><wddxPacket version='1.0'><header/><data><struct><var name='foo'><array length='2'><boolean value='true'/><string>stringvalue</string></array></var></struct></data></wddxPacket></pre>array(2) { [0]=> bool(true) [1]=> string(11) "stringvalue" } <p>array(2) { [0]=> bool(true) ["foo"]=> string(11) "stringvalue" } A possible solution would be to include always the index when serializing an array, be it numeric or string.