|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45877 Array key '2147483647' left as string
Submitted: 2008-08-21 03:04 UTC Modified: 2009-05-14 01:45 UTC
From: henryptung at gmail dot com Assigned: mattwil (profile)
Status: Closed Package: Arrays related
PHP Version: 5.2.6 OS: CentOS 4
Private report: No CVE-ID: None
 [2008-08-21 03:04 UTC] henryptung at gmail dot com
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');

Expected result:
array(2) {
  string(1) "d"
  string(1) "c"

Actual result:
array(3) {
  string(1) "b"
  string(1) "c"
  string(1) "d"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-21 07:18 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

use a 64bit machine for big integers
 [2009-03-17 18:45 UTC]
I had also noticed this issue awhile back. Finally created a simple fix so it works consistently and as expected, and will apply it soon, hopefully.
 [2009-03-18 01:12 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

Just fixed in 5.3 for now.
 [2009-05-14 01:45 UTC]
Also fixed in 5.2 now. See Bug #48254.
 [2010-10-05 13:29 UTC]
Automatic comment from SVN on behalf of dmitry
Log: Fixed bug #51008 (Zend/tests/bug45877.phpt fails)
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon May 29 13:03:45 2023 UTC