ARRAY_MERGE




  1. ARRAY_MERGE
array_merge — Merge one or more arrays
Description
array array_merge ( array $array1 [, array $array2 [, array $...]] )
array_merge() merges the elements of one or more arrays together so that the values of one are appended to the end of the previous one. It returns the resulting array.
If the input arrays have the same string keys, then the later value for that key will overwrite the previous one. If, however, the arrays contain numeric keys, the later value will not overwrite the original value, but will be appended.
If only one array is given and the array is numerically indexed, the keys get reindexed in a continuous way.
Example . array_merge() example

<?php
$a = array('green', 'red', 'yellow');
$b = array('avocado', 'apple', 'banana');
$c = array_merge($a, $b);

foreach ($d as $k=>$v)
{
	echo "$k $v";
	echo "<br>";
}
?>

output is 
0 green
1 red
2 yellow
3 avocado
4 apple
5 banana

Post a Comment

Previous Post Next Post