Похоже, у вас есть два одинаковых массива внутри, и вам нужны concat [0] и [1] ключи для дней недели (от - до).Вот решение для вашей коллекции-как-массив:
<?php
$youHaveArray = [
0 => [
'mon' => [
3 => '10:00',
4 => '11:00',
5 => '12:00',
],
'tue' => [
3 => '11:00',
4 => '12:00',
],
],
1 => [
'mon' => [
3 => '10:30',
4 => '11:30',
5 => '12:30',
],
'tue' => [
3 => '11:30',
4 => '12:30',
],
]
];
$daysOfWeekYouHave = array_keys($youHaveArray[0]) + array_keys($youHaveArray[1]);
$weekFormated = [];
foreach ($daysOfWeekYouHave as $dayName) {
if (! isset($weekFormated[$dayName])) {
$weekFormated[$dayName] = [];
}
if (isset($youHaveArray[0][$dayName])) {
foreach ($youHaveArray[0][$dayName] as $dayKey => $dayStart) {
if (isset($youHaveArray[1][$dayName][$dayKey])) {
$dayEnd = $youHaveArray[1][$dayName][$dayKey];
$weekFormated[$dayName][$dayKey] = $dayStart.' - '.$dayEnd;
}
}
}
}
var_dump($weekFormated);
Результат:
array(2) {
'mon' =>
array(3) {
[3] =>
string(13) "10:00 - 10:30"
[4] =>
string(13) "11:00 - 11:30"
[5] =>
string(13) "12:00 - 12:30"
}
'tue' =>
array(2) {
[3] =>
string(13) "11:00 - 11:30"
[4] =>
string(13) "12:00 - 12:30"
}
}