I'm trying to merge these two arrays:
$array1 = array (
123 => array (
'minutes_watched' => 192.0,
'impressions_count' => 18
),
456 => array (
'minutes_watched' => 200.0,
'impressions_count' => 20
)
);
$array2 = array (
123 => array (
'ingested_trailers_count' => 3,
'ingested_shorts_count' => 2,
'ingested_features_count' => 1
),
456 => array (
'ingested_trailers_count' => 10,
'ingested_shorts_count' => 10,
'ingested_features_count' => 10
)
);
I would like to end up with this:
$merged = array (
123 => array (
'minutes_watched' => 192.0,
'impressions_count' => 18,
'ingested_trailers_count' => 3,
'ingested_shorts_count' => 2,
'ingested_features_count' => 1
),
456 => array (
'minutes_watched' => 200.0,
'impressions_count' => 20,
'ingested_trailers_count' => 10,
'ingested_shorts_count' => 10,
'ingested_features_count' => 10
)
);
And eventually with this:
$merged = array (
array(
'id' => 123
'minutes_watched' => 192.0,
'impressions_count' => 18,
'ingested_trailers_count' => 3,
'ingested_shorts_count' => 2,
'ingested_features_count' => 1
),
array(
'id' => 456
'minutes_watched' => 200.0,
'impressions_count' => 20,
'ingested_trailers_count' => 10,
'ingested_shorts_count' => 10,
'ingested_features_count' => 10
)
);
I can't seem to find a concise way of doing this without some clunky for loops. Surely there's some PHP array function that would handle this?