Bug #66173 [Com]: Can not access an array element by index

From: Date: Fri, 29 Nov 2013 01:52:35 +0000
Subject: Bug #66173 [Com]: Can not access an array element by index
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-183000@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66173&edit=1 ID: 66173 Comment by: phpmpan at mpan dot pl Reported by: to dot yashin at gmail dot com Summary: Can not access an array element by index Status: Open Type: Bug Package: Arrays related Operating System: ubuntu 13.10 PHP Version: 5.5.6 Block user comment: N Private report: N New Comment: It seems that: zend_hash_copy blindly copies string key from the source object's hash table to the target array's hash table. Numeric string keys are converted to numbers on array access and zend_hash_index_find is used, which chooses wrong hash, wrong nIndex is produced and finally wrong arBucket is choosen, which leads to the element not being found. Previous Comments: ------------------------------------------------------------------------ [2013-11-26 06:08:30] to dot yashin at gmail dot com Description: ------------ Can not access an array element by index after casting Test script: --------------- <?php $object = new StdClass(); $object->{'1'} = 'test'; /** * object(stdClass)#1 (1) { * ["1"]=> * string(4) "test" * } */ $array = (array) $object; /** * array(1) { * ["1"]=> * string(4) "test" * } */ var_dump($array[1]); // NULL var_dump($array['1']); // NULL Expected result: ---------------- var_dump($array['1']); // 'test' Actual result: -------------- var_dump($array['1']); // NULL ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66173&edit=1

« previous php.bugs (#183000) next »