By coincidence I ran into a very bizarre behaviour regarding PHP arrays and its keys. Consider this creation of an PHP array.
$arr[2250572483]=1;
//dump the array
var_dump($arr);
//Result:
array(1) { [-2044394813]=> int(1) }
Somehow the array key has changed its value to a completely different negative number. This led me to some further investigation which is still inconclusive.
In below example I loop between the number range 2250572300 and 2250572500. Time is scarces for me so I did not manage to pinpoint at what number this phenomenon starts occurring because I run out of memory looping through large range of numbers. I think it should be somewhere between 2100000000 and 4300000000.
$arr2 = array();
for($i=2250572300; $i<= 2250572500; $i++){
$arr2[$i]=$i;
}
echo "<pre>".var_export($arr2,true)."</pre>";
My question is: does anyone know how and why this is happening and is there anything that is currently being done to fix the problem?
Essentially this is a major design flaw within PHP and could potentially make PHP useless when you are working with numbers in arrays, examples being supplier, invoice, item numbers etc.
Thanks