ID: 42828 Updated by: [EMAIL PROTECTED] Reported By: ger dot kirill at gmail dot com -Status: Open +Status: Bogus Bug Type: Unknown/Other Function Operating System: Windows, Linux PHP Version: 5.2.4 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Previous Comments: ------------------------------------------------------------------------ [2007-10-02 11:40:31] ger dot kirill at gmail dot com Description: ------------ In this php version the internal array pointer after foreach is not always NULL even after the full cicle is made. Instead it points to the next key after the one which was current when the first change was made to the array we are currently iterating. Reproduce code: --------------- $ar = array('val1', 'val2', 'val3'); var_dump(key($ar)); echo '<br>'; foreach ($ar as $key=>$val) { echo $key.'=>'.$val.'<br>'; } var_dump(key($ar)); echo '-------'; foreach ($ar as $key=>$val) { echo $key.'=>'.$val.'<br>'; $ar[2] = $ar[2]; } var_dump(key($ar)); echo '-------'; foreach ($ar as $key=>$val) { echo $key.'=>'.$val.'<br>'; if ($key==1) $ar[2] = $ar[2]; } var_dump(key($ar)); Expected result: ---------------- int(0) 0=>val1 1=>val2 2=>val3 NULL ------- 0=>val1 1=>val2 2=>val3 NULL ------- 0=>val1 1=>val2 2=>val3 NULL Actual result: -------------- int(0) 0=>val1 1=>val2 2=>val3 NULL ------- 0=>val1 1=>val2 2=>val3 int(1) ------- 0=>val1 1=>val2 2=>val3 int(2) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42828&edit=1