note 69991 deleted from function.array-merge by salathe
| From: | salathe@php.net | Date: | Mon, 06 Sep 2021 22:47:39 +0000 |
| Subject: | note 69991 deleted from function.array-merge by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-216912@lists.php.net to get a copy of this message | ||
Note Submitter: BigueNique at yahoo dot ca
----
Needed an quick array_merge clone that preserves the keys:
<?php
// function array_join
// merges 2 arrays preserving the keys,
// even if they are numeric (unlike array_merge)
// if 2 keys are identical, the last one overwites
// the existing one, just like array_merge
// merges up to 10 arrays, minimum 2.
function array_join($a1, $a2, $a3=null, $a4=null, $a5=null, $a6=null, $a7=null, $a8=null, $a9=null,
$a10=null) {
$a=array();
foreach($a1 as $key=>$value) $a[$key]=$value;
foreach($a2 as $key=>$value) $a[$key]=$value;
if (is_array($a3)) $a=array_join($a,$a3,$a4,$a5,$a6,$a7,$a8,$a9,$a10);
return $a;
}
?>