[php-src] Issue #10791: Spread array append

From: Date: Mon, 06 Mar 2023 10:01:25 +0000
Subject: [php-src] Issue #10791: Spread array append
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243856@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10791 Author: mvorisek ### Description Currently spread operator can be used for almost anything. But not for array append. I propose the following to be supported: ``` <?php $arr = [1, 2]; $arr2 = [3, 4]; $arr[...] = $arr2; ``` Currently the best alternative is array_push but for single value the man [1] says: > If you use array_push() to add one element to the array, it's better to use $array[] = > because in that way there is no overhead of calling a function. So the same applies for more elements and having native spread array append would be faster and consitent with other spread language syntax. [1] https://www.php.net/manual/en/function.array-push.php

« previous php.bugs (#243856) next »