note 102678 added to function.array-merge
| From: | TimothyArmstrong at osu1 dot php dot net | Date: | Mon, 28 Feb 2011 15:04:27 +0000 |
| Subject: | note 102678 added to function.array-merge | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-177406@lists.php.net to get a copy of this message | ||
To respond to Bob's post, there is a much simpler way to merge a dynamic number of arrays
together:
<?php
// assuming $someArrays is an array of the arrays we want to merge
$mergedArray = call_user_func_array('array_merge', $someArrays);
?>
This is a lot simpler than using the for-loop. Using call_user_func_array is a simple way to call
any function whenever you don't know the number of parameters.
----
Server IP: 69.147.83.197
Probable Submitter: 66.207.222.14
----
Manual Page -- http://www.php.net/manual/en/function.array-merge.php
Edit -- https://master.php.net/note/edit/102678
Del: integrated -- https://master.php.net/note/delete/102678/integrated
Del: useless -- https://master.php.net/note/delete/102678/useless
Del: bad code -- https://master.php.net/note/delete/102678/bad+code
Del: spam -- https://master.php.net/note/delete/102678/spam
Del: non-english -- https://master.php.net/note/delete/102678/non-english
Del: in docs -- https://master.php.net/note/delete/102678/in+docs
Del: other reasons-- https://master.php.net/note/delete/102678
Reject -- https://master.php.net/note/reject/102678
Search -- https://master.php.net/manage/user-notes.php