note 102576 deleted from function.array-merge by danbrown
| From: | danbrown@php.net | Date: | Thu, 03 Mar 2011 19:15:40 +0000 |
| Subject: | note 102576 deleted from function.array-merge by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-177540@lists.php.net to get a copy of this message | ||
Note Submitter: bobkruithof at gmail dot com
----
If you have a dynamic number of arrays ( sometimes 10, sometimes 15 or so ) stored in $someArrays,
you can still merge them all together.
<?php
$amountOfArrays = count( $someArrays );
$mergedArray = Array();
for( $i=0; $amountOfArrays; $i++ ) {
$mergedArray = array_merge( $mergedArray, $someArrays[$i] );
}
?>
Voila, you now hoave ALL the arrays in $someArrays merged together into $mergedArray :D