ID:               46279
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jozefchutka at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Arrays related
 Operating System: windows
 PHP Version:      5.2.6
 New Comment:

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


Previous Comments:
------------------------------------------------------------------------

[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/?id=46279&edit=1

Reply via email to