From: Operating system: Windows XP PHP version: 5.3.2 Package: Arrays related Bug Type: Bug Bug description:Array output unexpected result
Description: ------------ Code typed below generates unexpected result in the [0] term from an array. Test script: --------------- for ($i=0;$i<3;$i++) { $array_id=array( 0 => 0 , 1 => 1 , 2 => 2 ); $array_id[$i]="x"; for ($j=0;$j<3;$j++) { print "term [$j] is $array_id[$j]"; if ($array_id[$j]!=$j) print ", not $j"; print "<BR>\n"; } print "<BR>\n"; } Expected result: ---------------- term [0] is x, not 0 term [1] is 1 term [2] is 2 term [0] is 0 term [1] is x, not 1 term [2] is 2 term [0] is 0 term [1] is 1 term [2] is x, not 2 Actual result: -------------- array[0] is x array[1] is 1 array[2] is 2 array[0] is 0 array[1] is x, not 1 array[2] is 2 array[0] is 0 array[1] is 1 array[2] is x, not 2 -- Edit bug report at http://bugs.php.net/bug.php?id=51829&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51829&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51829&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51829&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=51829&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51829&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=51829&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=51829&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=51829&r=needscript Try newer version: http://bugs.php.net/fix.php?id=51829&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=51829&r=support Expected behavior: http://bugs.php.net/fix.php?id=51829&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=51829&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=51829&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=51829&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51829&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=51829&r=dst IIS Stability: http://bugs.php.net/fix.php?id=51829&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=51829&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=51829&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=51829&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=51829&r=mysqlcfg