I'm trying to merge two arrays where the main key matches, I tried using array_merge but the key is just overwritten.
For example I have this array:
$date = '2017-08-01';
$price_arr_1 = array();
$price_arr_1[$date]['adult_1'] = 10;
$price_arr_1[$date]['child_1'] = 2;
print_r($price_arr_1);
Which outputs:
Array ( [2017-08-01] => Array ( [adult_1] => 10 [child_1] => 2 ) )
And I have this array:
$date = '2017-08-01';
$price_arr_2 = array();
$price_arr_2[$date]['adult_2'] = 10;
$price_arr_2[$date]['child_2'] = 2;
print_r($price_arr_2);
Which outputs:
Array ( [2017-08-01] => Array ( [adult_2] => 10 [child_2] => 2 ) )
When I try and merge them like this:
print_r(array_merge($price_arr_1,$price_arr_2));
It output this:
Array ( [2017-08-01] => Array ( [adult_2] => 10 [child_2] => 2 ) )
I want to output this:
Array ( [2017-08-01] => Array ( [adult_1] => 10 [adult_2] => 10 [child_1] => 2 [child_2] => 2 ) )
Appreciated any ideas as to how to achieve the above!