#31125 [NEW]: two foreach loops in a row produce 2 diff results
| From: | dennis at inmarket dot lviv dot ua | Date: | Thu, 16 Dec 2004 14:25:56 +0000 |
| Subject: | #31125 [NEW]: two foreach loops in a row produce 2 diff results | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-70361@lists.php.net to get a copy of this message | ||
From: dennis at inmarket dot lviv dot ua
Operating system: WinXP
PHP version: 5.0.1
PHP Bug Type: Zend Engine 2 problem
Bug description: two foreach loops in a row produce 2 diff results
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 bug report at http://bugs.php.net/?id=31125&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=31125&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31125&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31125&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=31125&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=31125&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=31125&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=31125&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=31125&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=31125&r=support
Expected behavior: http://bugs.php.net/fix.php?id=31125&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=31125&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=31125&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=31125&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=31125&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=31125&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=31125&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=31125&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=31125&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=31125&r=mysqlcfg