ID: 26396 Updated by: [EMAIL PROTECTED] Reported By: php dot net dot 1 at odi dot ch -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: Win32 PHP Version: 4.3.3 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 You can not nest foreach calls. Previous Comments: ------------------------------------------------------------------------ [2003-11-25 04:58:19] php dot net dot 1 at odi dot ch Description: ------------ The behaviour of foreach seems to be scope dependent. The following code (slightly more than 20 lines) should yield the same results in both cases, but doesn't. I know that foreach uses the internal array pointer. The result beeing "de" or "de fr it" is NOT the topic here. The point is that the two results differ, although the code is the same except for the scope. This could be the reason for bug #19285 Reproduce code: --------------- <?php $usr_langs = array('de', 'fr', 'it'); function f() { global $usr_langs; foreach($usr_langs as $lang) { # do something } } function g() { global $usr_langs; foreach ($usr_langs as $lang) { f(); echo "$lang "; } } echo "Test1:<br>"; g(); echo "<br>----------<br>"; echo "Test2:<br>"; foreach ($usr_langs as $lang) { f(); echo "$lang "; } ?> Expected result: ---------------- Test1: de ---------- Test2: de OR even better Test1: de fr it ---------- Test2: de fr it Actual result: -------------- Test1: de ---------- Test2: de fr it ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26396&edit=1