|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-05-02 04:00 UTC] phpbugs at delinked dot net
Description:
------------
If an array is unserialized where a numerical key is represented as a string (s:3:"123"), the key and its value become inaccessible via direct access ($array[123]) as well as via isset, is_*, array_key_exists, var_dump, etc. The key and value are accessible via var_dump of the whole array, or via foreach.
Reproduce code:
---------------
<?php
$bob = unserialize('a:1:{s:5:"words";a:1:{s:3:"123";s:3:"foo";}}');
echo var_dump($bob);
echo var_dump($bob['words']['123']);
$id1 = '123';
echo var_dump($bob['words'][$id1]);
$id2 = 123;
echo var_dump($bob['words'][$id2]);
echo 0+isset($bob['words']['123']),0+isset($bob['words'][$id1]),0+isset($bob['words'][$id2]);
echo 0+array_key_exists('123',$bob['words']),0+array_key_exists($id1,$bob['words']),0+array_key_exists($id2,$bob['words']);
?>
Expected result:
----------------
array(1) {
["words"]=>
array(1) {
[123]=>
string(3) "foo"
}
}
string(3) "foo"
string(3) "foo"
string(3) "foo"
111111
- OR -
array(1) {
["words"]=>
array(1) {
["123"]=>
string(3) "foo"
}
}
string(3) "foo"
string(3) "foo"
string(3) "foo"
111111
Actual result:
--------------
array(1) {
["words"]=>
array(1) {
["123"]=>
string(3) "foo"
}
}
NULL
NULL
NULL
000000
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Tue Feb 10 03:00:01 2026 UTC |
Unable to reproduce on: Windows XP 32/64bit Windows 2003 Web/Standard/Enterprise Windows 2000 Server Results are exactly the same from each OS: array(1) { ["words"]=> array(1) { [123]=> string(3) "foo" } } string(3) "foo" string(3) "foo" string(3) "foo" 111111