<?php
$season_data = [
'Paul' => [
'Season' => [2014, 2015, 2016]
],
'John' => [
'Season' => [2012]
]
];
$appearance_data = [
'Paul' => [
'Appearance'=> [
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2015, 2015, 2015
]
],
'John' => [
'Appearance' => [
2012, 2012, 2012, 2012
]
]
];
foreach ($season_data as $person => $data) {
foreach ($data['Season'] as $year) {
$result[$person]['SeasonCounts'][$year] = sizeof(array_filter(
$appearance_data[$person]['Appearance'],
function($v) use ($year) {
return $v == $year;
}));
}
}
var_export($result);
preferences:
25.29 ms | 405 KiB | 5 Q