note 102576 modified in function.array-merge by danbrown

[email protected] Tue, 22 Feb 2011 08:27:44 -0800
Newsgroups php.notes
Message-ID <[email protected]>
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