|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-01-08 22:17 UTC] tpunt@php.net
[2017-12-26 12:06 UTC] nikic@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: nikic
[2017-12-26 12:06 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 21 07:00:01 2025 UTC |
Description: ------------ I've been working on updating the referenced array while in loop, when I encountered an issue with array_merge - basically the code below will run indefinitely. If you'll change the `$value == 'a'` to `$value == 'b'` the code will successfully finish (the issue will occur for any non-last element of array); While array_merge doesn't solve my initial issue (as it seems to be working on array copy), I don't think such behavior is valid. Test script: --------------- <?php $array = array('a','b'); $t = &$array; foreach($t as $value) if ($value == 'a') $t = array_merge($t, array('c')); else echo($value); var_dump($array); ?> Expected result: ---------------- b array 0 => string 'a' (length=1) 1 => string 'b' (length=1) 2 => string 'c' (length=1) Actual result: -------------- Fatal error: Maximum execution time of 30 seconds exceeded