|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-12-27 10:38 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 05:00:01 2025 UTC |
Description: ------------ as php manual says about array: As of PHP 4.3.0, the index generation behaviour described above has changed. Now, if you append to an array in which the current maximum key is negative, then the next key created will be zero (0). Before, the new index would have been set to the largest existing key + 1, the same as positive indices are. so here is the problem: Reproduce code: --------------- <?php $max=mt_getrandmax(); //2147483647 $arr=array($max=>1); //first $arr[]=2; //second $arr[]=3; //third $arr[]=4; //forth var_dump($arr); ?> so, according to php manual, "$arr[]=2" return "[-2147483648]=>int(2)",now, There is two options: 1. suppose that -2147483648(int)<2147483647(int) so, 2147483647 is still current maximum key, so $arr[]=3; should return "[-2147483648]=>int(3)", and will overwrite $arr[]=2; 2. -2147483648>2147483647, as manual says, $arr[]=3 should return "[0]=>3" Actual result: -------------- array(4) { [2147483647]=> int(1) [-2147483648]=> int(2) [-2147483647]=> int(3) [-2147483646]=> int(4) }