ID: 40768
Updated by: [EMAIL PROTECTED]
Reported By: abc at def dot ghi
Status: Closed
Bug Type: Scripting Engine problem
Operating System: winxp
PHP Version: 5.2.1
New Comment:
A quick fix for those that can't update, is to access the key in the
inner loop:
$a=array(1,2,3);
$b=$a;
foreach($a as $A)
{
foreach($b as $B)
{
key($b);
echo "$A,$B\n";
break;
}
}
Ouputs:
1,1
2,1
3,1
Previous Comments:
------------------------------------------------------------------------
[2007-03-19 19:56:17] [EMAIL PROTECTED]
Found this bug when looking at issue on PHP bug #40608.
Tested this example against the 5.2 snapshot
(php5.2-win32-200703191630.zip) from php.net, and it works properly.
So, looks like it has been fixed on the 5.2 branch after 5.2.1 was
released.
------------------------------------------------------------------------
[2007-03-09 18:30:56] abc at def dot ghi
me again,
i just tried latest snapshot and it works fine there so i guess new
snapshot should be released as i walked around some other strange things
in that current 5.2.1.
------------------------------------------------------------------------
[2007-03-09 18:20:01] abc at def dot ghi
wonder if someone can check this on linux build if its win issue.
------------------------------------------------------------------------
[2007-03-09 18:13:08] abc at def dot ghi
Description:
------------
i use just build i downloaded from site (5.2.1) no exts, no
optimizers.
it seem the $a,$b keep same internal pointer, this is quite serious
error cos $b=$a should create separate array copy and it does but
without the inner pointer.
if you replace $b=$a with $b=array(1,2,3); it works as expected
this was reported and ignored by someone on solaris before as well--
#40608
Reproduce code:
---------------
$a=array(1,2,3);
$b=$a;
foreach($a as $A)
{
foreach($b as $B)
{
echo "$A,$B\n";
break;
}
}
Expected result:
----------------
1,1
2,1
3,1
Actual result:
--------------
1,1
2,1
3,1
2,1
3,1
2,1
3,1
--infinite-
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40768&edit=1