I am trying to add keys to each of these two arrays so that I can access all the data as one array. Here is what I have. Tried multiple posts on Stack Overflow but so far nothing has concreted this concept for me:
$result = array();
$age_men = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
$age_women = array("Sally"=>"32", "Debra"=>"30", "Miranda"=>"40");
$result += ["Men" => $age_men];
$result += ["Women" => $age_women];
print_r($result);
//desired output
Array
(
[Men] => Array
(
[Peter] => 35
[Ben] => 37
[Joe] => 43
)
[Women] => Array
(
[Sally] => 32
[Debra] => 30
[Miranda] => 40
)
)