#45877 [Opn->Bgs]: Array key '2147483647' left as string
| From: | johannes@php.net | Date: | Thu, 21 Aug 2008 07:18:05 +0000 |
| Subject: | #45877 [Opn->Bgs]: Array key '2147483647' left as string | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-128275@lists.php.net to get a copy of this message | ||
ID: 45877
Updated by: johannes@php.net
Reported By: henryptung at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Arrays related
Operating System: CentOS 4
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
use a 64bit machine for big integers
Previous Comments:
------------------------------------------------------------------------
[2008-08-21 03:04:14] henryptung at gmail dot com
Description:
------------
I believe '2147483647' (= 2^31 - 1) should be the standard
representation of a valid integer, but using the string form as an array
key stores the key as a string, not an integer. The integer key
2147483647 can be used separately to refer to a different value, and
both are stored. See repro code below:
Note: this bug is admittedly duplicate of bug #13407, but the bug still
exists, and I fail to understand why the original bug was marked bogus.
Thanks for your time.
Reproduce code:
---------------
$v = array('2147483647' => 'b', '2147483646' => 'c',
2147483647 =>
'd');
var_dump($v);
Expected result:
----------------
array(2) {
[2147483647]=>
string(1) "d"
[2147483646]=>
string(1) "c"
}
Actual result:
--------------
array(3) {
["2147483647"]=>
string(1) "b"
[2147483646]=>
string(1) "c"
[2147483647]=>
string(1) "d"
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45877&edit=1