Edit report at http://bugs.php.net/bug.php?id=46279&edit=1
ID: 46279 Comment by: dalonso at sistemio dot com Reported by: jozefchutka at gmail dot com Summary: next() behaviour inside foreach changed Status: Bogus Type: Bug Package: Arrays related Operating System: windows PHP Version: 5.2.6 Block user comment: N New Comment: it also happens the same with each method () with each() method Previous Comments: ------------------------------------------------------------------------ [2008-10-13 09:44:48] tony2...@php.net Note: Unless the array is referenced, foreach operates on a copy of the specified array and not the array itself. foreach has some side effects on the array pointer. Don't rely on the array pointer during or after the foreach without resetting it. http://php.net/foreach ------------------------------------------------------------------------ [2008-10-12 11:14:40] jozefchutka at gmail dot com Description: ------------ there is a bug in 5.2.6 causing unexpected results when using next() function indisde foreach. Results from php 5.1, or 4.x are as expected. Reproduce code: --------------- <?php $arr=array('a','b','c', 'd','e'); foreach($arr as $a){ print_r($a); echo " next is: "; print_r(next($arr)); echo "<br />"; } ?> Expected result: ---------------- a next is: b b next is: c c next is: d d next is: e e next is: Actual result: -------------- a next is: c b next is: d c next is: e d next is: e next is: ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=46279&edit=1