From: allyouneedis at gmail dot com Operating system: Windows7 PHP version: 5.3.0 PHP Bug Type: Arrays related Bug description: wrong count() behaviour
Description: ------------ count counts one element to much on a freshly created array, goes to normal behaviour after unset() (apache newest stable, php newest stable, fresh setup just to confirm the bug, windows 7) Reproduce code: --------------- <?php $sockets = array(0,1,2,3,4,5); for($i=0,$j=count($sockets);$i<$j;++$i)echo $sockets[$i]; echo '<br>'; for($i=0,$j=count($sockets)+1;$i<$j;++$i)echo $sockets[$i]; echo '<hr>'; unset($sockets[3]); for($i=0,$j=count($sockets);$i<$j;++$i)echo $sockets[$i]; echo '<br>'; for($i=0,$j=count($sockets)+1;$i<$j;++$i)echo $sockets[$i]; ?> Expected result: ---------------- 01234<br>012345<hr>0124<br>01245 Actual result: -------------- 012345<br>012345<hr>0124<br>01245 -- Edit bug report at http://bugs.php.net/?id=48897&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48897&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48897&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48897&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48897&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48897&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48897&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48897&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48897&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48897&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48897&r=support Expected behavior: http://bugs.php.net/fix.php?id=48897&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48897&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48897&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48897&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48897&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48897&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48897&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48897&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48897&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48897&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48897&r=mysqlcfg