I have the following two arrays:
Array ( [Jonah] => 27 [Bianca] => 32
Array ( [Jonah] => 2 [Bianca] => 7
Is it possible to merge them together to form a multidimensional array in this format?
Array ( [0] => Array
( [name] => Jonah
[age] => 27
[number] => 2 )
[1] => Array
( [name] => Bianca
[age] => 32
[number] => 7 )
)
A temporary array keyed by name stores the values from the first two arrays. The temporary array is then copied to a final array keyed numerically:
Note: The last step of copying the array to make it numerically isn’t strictly needed, if you’re ok with your output array being keyed by name. In that case,
$tmpis the final product.