#31125 [Opn->Bgs]: two foreach loops in a row produce 2 diff results

From: Date: Thu, 16 Dec 2004 14:44:00 +0000
Subject: #31125 [Opn->Bgs]: two foreach loops in a row produce 2 diff results
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-70366@lists.php.net to get a copy of this message
ID: 31125 Updated by: derick@php.net Reported By: dennis at inmarket dot lviv dot ua -Status: Open +Status: Bogus Bug Type: Zend Engine 2 problem Operating System: WinXP PHP Version: 5.0.1 New Comment: Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Thank you for your interest in PHP. Then reopen the old report! Never submit something twice. Duplicate of #31118 Previous Comments: ------------------------------------------------------------------------ [2004-12-16 15:25:55] dennis at inmarket dot lviv dot ua Description: ------------ Hey, just DONT CLOSE THE BUG IF YOU DON'T EVEN READ IT! (This is to tony2001@php.net, who closed bug 31118) here is SIMPLER TEST CASE - no modifications of the array itself - two foreach loops show different contents Reproduce code: --------------- $a = array('key1'=>'value1', 'key2'=>'value2', 'key3'=>'value3'); foreach($a as $k=>&$v) { echo $k . '=' . $v . "\r\n"; } foreach($a as $k=>$v) { echo $k . '=' . $v . "\r\n"; } // See? No values are modified!!! All explanations to other bugs do not cover this problem Expected result: ---------------- key1=value1 key2=value2 key3=value3 key1=value1 key2=value2 key3=value3 Actual result: -------------- key1=value1 key2=value2 key3=value3 key1=value1 key2=value2 key3=value2 <- should be 3 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31125&edit=1

« previous php.bugs (#70366) next »