#45877 [NEW]: Array key '2147483647' left as string

From: Date: Thu, 21 Aug 2008 03:04:14 +0000
Subject: #45877 [NEW]: Array key '2147483647' left as string
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-128272@lists.php.net to get a copy of this message
From: henryptung at gmail dot com Operating system: CentOS 4 PHP version: 5.2.6 PHP Bug Type: Arrays related Bug description: Array key '2147483647' left as string 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 bug report at http://bugs.php.net/?id=45877&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45877&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45877&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45877&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45877&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45877&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45877&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45877&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45877&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45877&r=support Expected behavior: http://bugs.php.net/fix.php?id=45877&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45877&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45877&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45877&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45877&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45877&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45877&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45877&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45877&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45877&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45877&r=mysqlcfg

« previous php.bugs (#128272) next »