Why does php array integer key get negative (<0)?
This is due to arithmetic overflow . Since the largest integer number in PHP is PHP_INT_MAX
, it is only 2147483647
(32-bit).
Thus, the "so-called" number 2147483648
will be overflowing, then it will come -2147483648
, 2147483649
become, -2147483647
and so on ...
Your number 4294967295
finally ends with -1.
All of this is because in computer science we use Two Complement to display less than 0 numbers. It doesn't make sense in real life, but for a computer, Two's Complement is much easier and faster to compute.
For your problem, you can change your PHP to 64 bit. Or get around it by not using the number, which in this case is> PHP_INT_MAX.
source share