note 70865 deleted from function.array-merge by cmb
| From: | cmb@php.net | Date: | Sun, 29 Sep 2019 07:32:01 +0000 |
| Subject: | note 70865 deleted from function.array-merge by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212399@lists.php.net to get a copy of this message | ||
Note Submitter:
----
A more efficient array_merge that preserves keys, truly accepts an arbitrary number of arguments,
and saves space on the stack (non recursive):
<?php
function array_merge_keys(){
$args = func_get_args();
$result = array();
foreach($args as &$array){
foreach($array as $key=>&$value){
$result[$key] = $value;
}
}
return $result;
}
?>