ID: 50423 User updated by: anton at zebooka dot com Reported By: anton at zebooka dot com Status: Bogus Bug Type: Arrays related Operating System: Ubuntu 9.10 PHP Version: 5.2.11 New Comment:
Oh, hell. I know what is written in documentation. But this is clearly a bug. Why can't you open console, type "php -a" and test it your self??? For unbelievers: php > $o = new stdClass(); php > $o->{123} = 456; php > echo $o->{123}; 456 So object HAS!!! numerical properties. php > var_dump($o); object(stdClass)#1 (1) { ["123"]=> int(456) } php > var_dump($a); array(1) { ["123"]=> int(456) } php > error_reporting(-1); php > var_dump($a[123]); Notice: Undefined offset: 123 in php shell code on line 1 NULL There is still no bug??? Are you kidding? PHP team should either disable assigning properties with numberical names to objects (throw ->{} syntax and with (object) cast), or convert objects to arrays and arrays to objects normally, without such bells and candies. :) Previous Comments: ------------------------------------------------------------------------ [2009-12-09 12:16:31] j...@php.net "If an object is converted to an array , the result is an array whose elements are the object 's properties. The keys are the member variable names, with a few notable exceptions: integer properties are unaccessible;" And this is exactly what happens. No bug here. ------------------------------------------------------------------------ [2009-12-09 09:47:48] johan...@php.net sorry misread it ------------------------------------------------------------------------ [2009-12-09 09:45:17] anton at zebooka dot com Yes, I can't. But I have!!! Look closer. Expected result is, when I convert object with numerially named properties, to get array with int keys. But instead I get an array with string numerical keys ------------------------------------------------------------------------ [2009-12-09 09:41:15] johan...@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php You can\'t have array keys with numeric strings as key. ------------------------------------------------------------------------ [2009-12-09 09:36:10] anton at zebooka dot com Again, if you then do echo $a[0]; you'll get 123 instead of 456. Even if you call arsort($a); the result will be the same - 123. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/50423 -- Edit this bug report at http://bugs.php.net/?id=50423&edit=1