Bug #68215 [Opn->Fbk]: Behavior of foreach has changed
| From: | derick@php.net | Date: | Mon, 13 Oct 2014 11:25:28 +0000 |
| Subject: | Bug #68215 [Opn->Fbk]: Behavior of foreach has changed | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-188063@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68215&edit=1
ID: 68215
Updated by: derick@php.net
Reported by: pegasus at vaultwiki dot org
Summary: Behavior of foreach has changed
-Status: Open
+Status: Feedback
Type: Bug
Package: Scripting Engine problem
Operating System: Centos 6 64-bit
PHP Version: master-Git-2014-10-13 (Git)
Block user comment: N
Private report: N
New Comment:
Can you please provide a reproducible case as a short PHP script?
Previous Comments:
------------------------------------------------------------------------
[2014-10-13 03:13:07] pegasus at vaultwiki dot org
Description:
------------
Historically, foreach ($arr AS $val) has acted on a copy of $arr, in order to prevent issues if $arr
entries are modified after the loop has already begun iterating. If the current value was desired,
historically for or while loops were used instead.
However, in Master, it appears that $arr always refers to the current value of $arr. This is in
contradiction to the historical behavior. If entries are added inside the loop, foreach will keep
going for the new entries. If existing entries are otherwise modified, the $val corresponds to the
updated entry rather than the $val when the loop began.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68215&edit=1