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

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.


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

[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