note 43187 added to function.array-merge
| From: | nivatNOSPAMiaglansdotDE at rn2 dot php dot net | Date: | Sat, 12 Jun 2004 14:18:39 +0000 |
| Subject: | note 43187 added to function.array-merge | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-70973@lists.php.net to get a copy of this message | ||
i recognized there is no function with that you can add two number-Arrays:
Example:
you have two arrays:
array1 = array (['0'] =>"blahblupp",
['1'] => "bluppblah" );
array2 = array (['0'] =>"tirili",
['1'] => "tralala" );
and want following as a result:
result = array (['0'] =>"blahblupp",
['1'] => "bluppblah",
['2'] =>"tirili",
['3'] => "tralala" )
following function does the addition:
function array_add($array1, $array2)
{
$result = $array1;
$h = sizeof($array1);
for ($i = 0; $i < sizeof($array2); $i++)
{
$result[$h] = $array2[$i];
$h++;
}
return $result;
}
just added because I didn't find a ready-to-use script here.
----
Manual Page -- http://www.php.net/manual/en/function.array-merge.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43187
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43187&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43187&report=yes
Search -- http://master.php.net/manage/user-notes.php