Syntax of array_merge_recursive in PHP
array array_merge_recursive(array array1, array array2[, … array arrayN])
Like array_merge(), creates and returns an array by appending each input array to the previous. However, unlike array_merge(), when multiple elements have the same string key, an array containing each value is inserted into the resulting array
<?php
$ar1 = array("color" => array("favorite" => "red"), 5);
$ar2 = array(10, "color" => array("favorite" => "green", "blue"));
$result = array_merge_recursive($ar1, $ar2);
print_r($result);
?>
Output
Array
(
[color] => Array
(
[favorite] => Array
(
[0] => red
[1] => green
)
[0] => blue
)
[0] => 5
[1] => 10
)