#35813 [NEW]: arrays problem
From: songchao1234 at yeah dot net
Operating system: redhat 7.3
PHP version: 5.1.1
PHP Bug Type: Variables related
Bug description: arrays problem
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)
}
--
Edit bug report at http://bugs.php.net/?id=35813&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=35813&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=35813&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=35813&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=35813&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=35813&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=35813&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=35813&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=35813&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=35813&r=support
Expected behavior: http://bugs.php.net/fix.php?id=35813&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=35813&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=35813&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=35813&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35813&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=35813&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=35813&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=35813&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=35813&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=35813&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=35813&r=mysqlcfg
Thread (2 messages)
- songchao1234 at yeah dot net