$minutes = ['03', '09', '13', '18', '23', '28'];
var_dump(getRange($minutes));
function getRange($minutes): array
{
if(count($minutes) < 5) return $minutes;
$minutes = array_map(fn($m) => intval($m), $minutes);
rsort($minutes);
$ranges = [];
foreach ($minutes as $k => $minute){
if($k){
$ranges[] = $prev - $minute;
}
$prev = $minute;
}
$min = min($ranges);
$max = max($ranges);
return $min === $max
? [$max]
: [$min, $max];
}