$block = array(0 => 'Пн', 1 => 'Ср', 2 => 'Чт', 3 => 'Пт');
$block = array(0 => 'Вт', 1 => 'Ср', 2 => 'Чт', 3 => 'Сб');
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);
}