php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79422 Feature request - allow to append multiple elements to an array
Submitted: 2020-03-27 19:57 UTC Modified: 2020-03-28 22:42 UTC
From: michael dot vorisek at email dot cz Assigned:
Status: Suspended Package: Scripting Engine problem
PHP Version: 7.4.4 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: michael dot vorisek at email dot cz
New email:
PHP Version: OS:

 

 [2020-03-27 19:57 UTC] michael dot vorisek at email dot cz
Description:
------------
This is a feature request / RFC for the following use-case:

$res = [];
foreach ($arr as $i) {
    foreach (make_res($i) as $v) {
        $res[] = $v;
    }
}

Array_merge in loop is very sloop so it is not a solution.

which I propose to shorten to:

$res = [];
foreach ($arr as $i) {
    $res[...] = make_res($i);
}

Appending multiple elements to an array is very common use-case.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-03-28 22:42 UTC] requinix@php.net
-Status: Open +Status: Suspended
 [2020-03-28 22:42 UTC] requinix@php.net
This is not the place to make language suggestions. Check out the RFC process at
https://wiki.php.net/rfc/howto
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 10:01:33 2025 UTC