function group_days($block) {
$week = array('Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб');
$res = [];
foreach ($block as $id=>$day) {
if ($id == 0) {
$period = [$day];
} else {
if (array_search($day, $week)-array_search(end($period), $week)==1) {
$period[1] = $day;
} else {
$res[] = $period;
$period = [$day];
}
}
}
$res[] = $period;
$res = array_map(
function($el) {return implode('-', $el);},
$res
);
return implode(', ', $res);
}