note 102576 modified in function.array-merge by danbrown
| From: | danbrown@php.net | Date: | Tue, 22 Feb 2011 16:27:44 +0000 |
| Subject: | note 102576 modified in function.array-merge by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-177221@lists.php.net to get a copy of this message | ||
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
--was--
If you have a dynamic number of arrays ( sometimes 10, sometimes 15 or so ) stored in $someArrays,
you can still merge them all together.
$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
http://php.net/manual/en/function.array-merge.php