051 - array_merge ( mearge two array and creater another one )Array
(
[0] => one
[1] => two
[2] => three
[3] => carrot
[4] => pea
[5] => english
[6] => science
)
Array
(
[0] => one
[1] => two
[2] => three
[3] => carrot
[4] => pea
[5] => english
[6] => science
[a] => roti
[b] => halwa
[c] => kheer
)
Array
(
[a] => roti
[b] => halwa
[c] => milk
[d] => chai
[e] => lassi
)
Array
(
[a] => roti
[b] => halwa
[c] => kheer
[d] => chai
[e] => lassi
)
Array
(
[0] => one
[1] => two
[2] => three
[f] => milk
[g] => chai
[h] => lassi
[3] => 55
[4] => 19
)
<?php
// 051 - array_merge ( mearge two array and creater another one )
echo "</br><span class='myheading'>051 - array_merge ( mearge two array and creater another one )</span></br>";
$fruit_051 = ["one", "two", "three"];
$veggie_051 = ['carrot', 'pea'];
$books_051 = ['english', 'science'];
$food_051 = ['a' => "roti", 'b' => "halwa", 'c' => "kheer"];
$drink_051 = ['c' => "milk", 'd' => "chai", 'e' => "lassi"];
$city_051 = ['f' => "milk", 'g' => "chai", 'h' => "lassi",55,023];
$newArray_051 = array_merge($fruit_051,$veggie_051,$books_051); // new array by mearging
echo "<pre>";
print_r($newArray_051);
echo "</pre>";
$newArray_a_051 = array_merge($fruit_051,$veggie_051,$books_051,$food_051); // index & aA array
echo "<pre>";
print_r($newArray_a_051);
echo "</pre>";
$newArray_b_051 = array_merge($food_051,$drink_051); // aA array with same key
echo "<pre>";
print_r($newArray_b_051);
echo "</pre>";
$newArray_b_051 = array_merge($food_051 + $drink_051); // above but now original repalce the second array value
echo "<pre>";
print_r($newArray_b_051);
echo "</pre>";
$newArray_c_051 = array_merge($fruit_051,$city_051); // aA array with numberic values
echo "<pre>";
print_r($newArray_c_051);
echo "</pre>";
?>