ID:               45348
 Updated by:       [EMAIL PROTECTED]
 Reported By:      songqi at baidu dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Arrays related
 Operating System: Redhat Linux
 PHP Version:      5.2.6
 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

No, array_keys() isn't doing that. Numeric strings used as an array key
are converted to integer when the element is created. This can be seen
by removing array_keys() from your code:

<?php
$a = array('1'=>'abc','a'=>'1');
var_dump($a);
?>

And you will see:

array(2) {
  [1]=>
  string(3) "abc"
  ["a"]=>
  string(1) "1"
}

(Notice no quotes around the integer key.) And NOT:

array(2) {
  ["1"]=>
  string(3) "abc"
  ["a"]=>
  string(1) "1"
}


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

[2008-06-24 11:34:28] songqi at baidu dot com

Description:
------------
just look at the example

Reproduce code:
---------------
<?php
$a = array('1'=>'abc','a'=>'1');
var_dump(array_keys($a));
?>

Expected result:
----------------
array(2) {
  [0]=>
  string(1) "1"
  [1]=>
  string(1) "a"
}

Actual result:
--------------
array(2) {
  [0]=>
  int(1)
  [1]=>
  string(1) "a"
}


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


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

Reply via email to