ID:               39477
 Updated by:       [EMAIL PROTECTED]
 Reported By:      phpbug dot 20 dot antialias at spamgourmet dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: Mac OS X v. 10.4.8
 PHP Version:      5.2.0
 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

This is expected behaviour.


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

[2006-11-12 11:26:34] phpbug dot 20 dot antialias at spamgourmet dot
com

Description:
------------
foreach iterators are bound to the scope of their arrays. This 
causes problems when a global array has been partially 
iterated through, and then inside the foreach, the same global 
array is iterated through again. The the inner foreach 
iterator effectively completes the iterations of the outer 
foreach iterator, yielding unexpected results.


Reproduce code:
---------------
$t = array("1", "2");
global $t;
foreach($t as $a) {
        foreach($t as $b) {
                echo $b;
        }
        echo $a;
        
}

Expected result:
----------------
1212

Actual result:
--------------
121


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=39477&edit=1

Reply via email to