|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13407 array index "2147483647" not equivalent to 2147483647
Submitted: 2001-09-23 14:44 UTC Modified: 2002-08-13 22:59 UTC
From: trobinson at gksystems dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.0.4pl1 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: trobinson at gksystems dot com
New email:
PHP Version: OS:


 [2001-09-23 14:44 UTC] trobinson at gksystems dot com
echo $ar[2147483646];
echo $ar[2147483647];



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-09-23 14:52 UTC]
Integers are limited in capacity, you're too near the bounds of integer. If you need such high numbers, see GMP.

Not a bug. (though technically it could be possible to let this single number work, the next one will fail.)

Do a var_dump($ar) to see what happens.
 [2001-09-23 14:59 UTC]
Hrm..  Sure, that is the kneejerk response, but "too near"?  2147483647 is 2^31 - 1.  I could understand if this happened at 2^31+1 and up, but not at 2^31 - 1.  I'd like to see a better explanation of why this happens at  instead of at 21474836478
 [2001-09-23 15:06 UTC]
I assume there somewhere needs to be one more than the index, for some reason... people should, IMHO, realize that computers have limited capacity for integer numbers, well, at least most languages do.

And wether it goes wrong at max-1 or exactly at max, isn't really an issue IMO. You should not rely on the outer regions of the capacity of integer numbers.

But there is one other reason why this isn't bogus after all, because $ar[ digits ] and $ar[ "digits" ] (digits := [0-9]+ ) should be equivalent. This is true inside the bounds (because both come down to an integer), and outside the bounds (because both come down to the same string). But for this case it is NOT true... 
 [2001-12-14 14:15 UTC]
Any update for this?
 [2002-08-13 22:59 UTC]
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Oct 27 13:03:39 2021 UTC