ID:               50423
 Updated by:       johan...@php.net
 Reported By:      anton at zebooka dot com
-Status:           Bogus
+Status:           Open
 Bug Type:         Arrays related
 Operating System: Ubuntu 9.10
 PHP Version:      5.2.11
 New Comment:

sorry misread it


Previous Comments:
------------------------------------------------------------------------

[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.

------------------------------------------------------------------------

[2009-12-09 09:33:43] anton at zebooka dot com

Description:
------------
As mentioned in documentation, array items can have either string or
int. However keys that are numerical strings are converted to int.

This is how to create an array with item, which key is string, while it
is a number.

Reproduce code:
---------------
$a = array(123);
$o = (object) $a;
$o->{0} = 456;
$a = (array) $o;
var_dump($a);

Expected result:
----------------
array(2) {
  [0]=>
  int(456)
}

Actual result:
--------------
array(2) {
  [0]=>
  int(123)
  ["0"]=>
  int(456)
}


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=50423&edit=1

Reply via email to