ID:               50423
 User updated by:  anton at zebooka dot com
 Reported By:      anton at zebooka dot com
 Status:           Open
 Bug Type:         Arrays related
 Operating System: Ubuntu 9.10
 PHP Version:      5.2.11
 New Comment:

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.


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

[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