052 - array_merge_recursive ( merge associative array )Array
(
[a] => roti
[b] => halwa
[c] => Array
(
[0] => kheer
[1] => milk
)
[0] => 55
[1] => 68
[d] => chai
[e] => lassi
)
Array
(
[a] => roti
[b] => Array
(
[0] => halwa
[color] => Array
(
[0] => red
[1] => blue
[2] => green
)
)
[c] => kheer
[0] => 55
[1] => 68
[e] => pea
[2] => 55
[3] => 68
)
<?php
// 052 - array_merge_recursive ( merge associative array )
echo "</br><span class='myheading'>052 - array_merge_recursive ( merge associative array )</span></br>";
$food_052 = ['a' => "roti", 'b' => "halwa", 'c' => "kheer", 55, 68];
$drink_052 = ['c' => "milk", 'd' => "chai", 'e' => "lassi"];
$newArray_052 = array_merge_recursive($food_052,$drink_052); /* if common key built new array-- */
echo "<pre>";
print_r($newArray_052);
echo "</pre>";
$veggie_052 = ['b' => ['color' => ['red','blue','green']], /* ---- more complex multidim array ----*/
'e' => 'pea',
55,
68
];
$newArray_a_052 = array_merge_recursive($food_052,$veggie_052);
echo "<pre>";
print_r($newArray_a_052);
echo "</pre>";
?>