Search This Blog

add one arry to another array or append array in php

<?php
echo '<b>the first array :</b>';
$num1=array(1,2,3,4,5,6,7,8,9,10);
foreach($num1 as $num)
{
echo ' '.$num;
}
echo '<br><b>the second array :</b>';
$num2=array(11,12,13,14,15,16,17,18,19,20);
foreach($num2 as $num)
{
echo ' '.$num;
}
echo '<br><br><b>append the first array to the second array : </b>';

$num3 = array_merge($num1, $num2);

foreach($num3 as $num)
{
echo ' '.$num;
}

?>

output :

the first array : 1 2 3 4 5 6 7 8 9 10
the second array : 11 12 13 14 15 16 17 18 19 20

append the first array to the second array : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Share Links

Related Posts Plugin for WordPress, Blogger...