note 69991 added to function.array-merge
| From: | BigueNique at yahoo dot ca | Date: | Fri, 29 Sep 2006 02:10:16 +0000 |
| Subject: | note 69991 added to function.array-merge | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-117813@lists.php.net to get a copy of this message | ||
Needed an quick array_merge clone that preserves the keys:
<?
// 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;
}
?>
----
Server IP: 216.235.15.211
Probable Submitter: 64.18.184.17
----
Manual Page -- http://www.php.net/manual/en/function.array-merge.php
Edit -- https://master.php.net/note/edit/69991
Del: integrated -- https://master.php.net/note/delete/69991/integrated
Del: useless -- https://master.php.net/note/delete/69991/useless
Del: bad code -- https://master.php.net/note/delete/69991/bad+code
Del: spam -- https://master.php.net/note/delete/69991/spam
Del: non-english -- https://master.php.net/note/delete/69991/non-english
Del: in docs -- https://master.php.net/note/delete/69991/in+docs
Del: other reasons-- https://master.php.net/note/delete/69991
Reject -- https://master.php.net/note/reject/69991
Search -- https://master.php.net/manage/user-notes.php