ID: 47028
Comment by: kobieta dot ryba at gmail dot com
Reported By: kobieta dot ryba at gmail dot com
Status: Open
Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 6CVS-2009-01-07 (CVS)
New Comment:
Is there anybody reading this?
Previous Comments:
------------------------------------------------------------------------
[2009-01-07 14:33:21] kobieta dot ryba at gmail dot com
Description:
------------
I've noticed strange behavior when using references and foreach loop.
It throws an error "Invalid argument supplied for foreach" but if the
code
// $ass = &$array;
is commented out, the result is as expected:
Output:
in
in
in
Reproduce code:
---------------
<?
$array = array("1", "2", "3");
$ass = &$array;
foreach($array as $k => &$v)
{
$array = false;
$v = "Test";
echo "in\n";
}
?>
Expected result:
----------------
in
in
in
Actual result:
--------------
in
Warning: Invalid argument supplied for foreach() in test.php on line 5
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47028&edit=1