|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2014-11-11 14:25 UTC] ajf@php.net
 
-Status: Open
+Status: Not a bug
  [2014-11-11 14:25 UTC] ajf@php.net
  [2014-11-11 19:53 UTC] requinix@php.net
 
-Package: PHP Language Specification
+Package: *General Issues
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 07:00:01 2025 UTC | 
Description: ------------ Scenario: foreach with value as reference function which has foreach with value as reference and returns array last item of unmodified array changes to modified array item namechanges doesn't change scenario. Test script: --------------- $bar = [["object_name" => "first"], ["object_name" => "second"]]; foreach($bar as &$b) $b["object_name"] .= " foo"; function foo($bar){ foreach($bar as &$o) $o["object_name"] = "bar " . $o["object_name"]; return $bar; } function echoObjects($bar) { foreach($bar as $o) echo $o["object_name"] . "<br />"; echo "<br />"; } echoObjects($bar); echoObjects(foo($bar)); echoObjects($bar); //extra bar on last item Expected result: ---------------- first foo second foo bar first foo bar second foo first foo second foo Actual result: -------------- first foo second foo bar first foo bar second foo first foo bar second foo