Re: array_merge() inside looping optimization
| From: | Claude Pache | Date: | Mon, 26 Jul 2021 14:28:39 +0000 |
| Subject: | Re: array_merge() inside looping optimization | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-115587@lists.php.net to get a copy of this message | ||
> Le 26 juil. 2021 à 15:41, Sara Golemon <pollita@php.net> a écrit :
>
> A much more direct and maintainable solution would be to introduce a new
> function that intentionally modifies by reference.
That function already exists, it is
array_push():
$x = array_merge($x, $y); → array_push($x, ...$y)
—Claude