<?php
$movies = [
'MOVIE TITLE #1' => [
'id' => 11990,
'times' => [
'2023-06-03' => [
'11:00am',
'2:30pm',
'6:00pm',
'9:30pm',
],
'2023-06-04' => [
'12:30pm',
'4:00pm',
'7:30pm',
],
'2023-06-06' => [
'12:30pm',
'4:00pm',
'7:30pm',
],
],
],
'MOVIE TITLE #2' => [
'id' => 11892,
'times' => [
'2023-06-03' => [
'12:00pm',
'3:30pm',
'7:00pm',
],
],
],
];
$dates = array_flip(['2023-06-03', '2023-06-04']);
$result = [];
foreach ($movies as $title => ['times' => $times]) {
foreach (array_intersect_key($times, $dates) as $date => $times) {
$result[$date][$title] = $times;
}
}
var_export($result);
preferences:
23.64 ms | 406 KiB | 5 Q