$week = [
'Понедельник' => [0 => '9:00', 1 => '19:00'],
'Вторник' => [0 => '9:00', 1 => '19:00'],
'Среда' => [0 => '9:00', 1 => '19:00'],
'Четверг' => [0 => '10:00', 1 => '14:00'],
'Пятница' => [0 => '9:00', 1 => '19:00'],
'Суббота' => [0 => '9:00', 1 => '19:00'],
'Воскресенье' => [0 => '10:00', 1 => '16:00']
];
$data = [];
$current = '';
$i = 0;
foreach ($week as $day => $schedule) {
if ($current !== $schedule) {
$current = $schedule;
$data[$i++] = ['start' => $day, 'end' => $day, 'time' => implode(' - ', $schedule)];
}
$data[$i - 1]['end'] = $day;
}
foreach ($data as $id => $row) {
$data[$id] = [implode(' - ', array_unique([$row['start'], $row['end']])) => $row['time']];
}
var_dump($data);
на выходе:
'Понедельник - Среда' => '9:00 - 19:00'
'Четверг' => '10:00 - 14:00'
'Пятница - Суббота' => '9:00 - 19:00'
'Воскресенье' => '10:00 - 16:00'