|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48254 Inconsistent handling of huge numerical keys for array
Submitted: 2009-05-13 03:47 UTC Modified: 2009-05-14 01:42 UTC
From: for-bugs at hnw dot jp Assigned: mattwil (profile)
Status: Closed Package: Arrays related
PHP Version: 5.2.9 OS: *
Private report: No CVE-ID: None
 [2009-05-13 03:47 UTC] for-bugs at hnw dot jp
There is inconsistency in dealing with huge numerical array key.

We know PHP normalizes array key with numerical string to integer if possible. For instance, $a["1"] is equevalent to $a[1]. However, it is not valid about PHP_INT_MAX and ~PHP_INT_MAX (2147483647 and -2147483648 in 32bit envirionment).

Reproduce code:


Expected result:
array(2) {

Actual result:
array(2) {


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-13 14:25 UTC]
See Bug #45877.

This has been fixed in PHP 5.3. I didn't backport the change to 5.2 since it's been around forever and didn't know if the fix would be wanted in 5.2 (primarily by who's in charge of it) at this point in its lifecycle.

I'll leave this open for now to see if other devs have a comment...
 [2009-05-13 18:40 UTC]
Matt, bug fixes should go into PHP_5_2. And I guess this is the same 
patch needing MFB to HEAD too? :)
 [2009-05-14 01:42 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.

Taken care of now!

I know, Jani, and I've merged other fixes. :-) Just thought this might be considered, by others, more of a "feature change," since previous bug reports had been dismissed. And Dmitry, nor anyone else, said anything about including 5.2 when the change was made in HEAD/5.3 2 months ago...

Nope, this has nothing to do with the other part missing from HEAD. ;-) Even though I didn't personally commit this fix, it was done in HEAD as well. (I've changed the reported version back to 5.2.9)
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 26 00:03:37 2021 UTC