#48875 [Opn->Bgs]: unexpected foreach behavior with references, 2 foreaches, and same value var
| From: | jani@php.net | Date: | Fri, 10 Jul 2009 18:12:59 +0000 |
| Subject: | #48875 [Opn->Bgs]: unexpected foreach behavior with references, 2 foreaches, and same value var | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-139584@lists.php.net to get a copy of this message | ||
ID: 48875
Updated by: jani@php.net
Reported By: stepheneliotdewey at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Vista 64-bit
PHP Version: 5.2.10
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
Please, read the manual page too. This is documented there.
Previous Comments:
------------------------------------------------------------------------
[2009-07-10 00:40:56] stepheneliotdewey at gmail dot com
I should note that I first saw this bug in a comment posted earlier
today in the documentation:
http://us3.php.net/manual/en/control-structures.foreach.php#92116
------------------------------------------------------------------------
[2009-07-10 00:36:21] stepheneliotdewey at gmail dot com
Description:
------------
If you look at the final print-out for the below, it will print a, b,
b, instead of the expected a, b, c. I don't think this is the expected
behavior.
Reproduce code:
---------------
<?php
$a = array('a', 'b','c');
foreach($a as &$row){
//you don't have to do anything here
}
print_r($a);
foreach($a as $row){
echo "<br />".$row;
}
?>
Expected result:
----------------
a
b
c
Actual result:
--------------
a
b
b
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48875&edit=1