The goal is fast multi-item array append, which is currently not possible, as `+=` and `array_push` operators does something else and `array_merge` is very slow as the whole array is copied.
Currently the fastest approach is to use the foreach equivalent, which requires much more code and two intermediate variables for k/v. For better understanding, I have updated the example codes in https://github.com/php/php-src/issues/10791 but sadly all short codes are slow as array is copied. Michael ________________________________ From: Michał Marcin Brzuchalski <michal.brzuchal...@gmail.com> Sent: Thursday, April 6, 2023 5:01 PM To: Vorisek, Michael <voris...@fjfi.cvut.cz> Cc: PHP internals <internals@lists.php.net> Subject: Re: [PHP-DEV] Array spread append czw., 6 kwi 2023, 13:53 użytkownik Vorisek, Michael <voris...@fjfi.cvut.cz<mailto:voris...@fjfi.cvut.cz>> napisał: Hi Ilija, * Are integer keys preserved? I'm assuming no, as otherwise it would be the same as `$a + $b`. $arr[...] = $arr; should be the same as foreach ($arr as $v) { $arr[] = $v; } I'd argue with that because I think the spread operator should be consistent with preserve keys strategy used in other places. Cheers, Michał Marcin Brzuchalski