Not bothering with implementation of bisection

something similar to the code below, but functional would work. the code
below fails on a few use cases:

'1.2.3.4.5.6'
'0.1.3.4.6'
'0.1.2.4.5.6'

function _bisect($list, $sequences) {
	$listSize = count($list);
	if($listSize == 0){
		return null;
	}
	$first = $list[0];
	$last = $list[$listSize -1];
	$shortcut = $first + $listSize - 1;
	if($shortcut == $last){
		$sequences[] = array($first,$last);
		return array($first,$last);
	}else{
		$right = _bisect(  array_splice($list, ceil($listSize/2)
) , $sequences);
		$left = _bisect( $list , $sequences);
		if(!is_null($right)) $sequences[] = $right;
		if(!is_null($left)) $sequences[] = $left;
	}
	return $sequences;
}

function bisect($daylist){
	$daylistNums = explode('.',$daylist);
	sort($daylistNums);
	$seq = 0;
	$sequences = array();
	_bisect($daylistNums, &$sequences);

	if(!is_array($sequences[0])){
		$sequences = array($sequences);
	}

	/* Convert Sequences into the days string */
	$dayStrs = array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
	$daylistStrings = array();
	foreach ($sequences as $sequence) {
		$start = $sequence[0];
		$end = $sequence[1];
		if($start == $end){
			$daylistStrings[] = $dayStrs[$start];
		}else{
			$daylistStrings[] = $dayStrs[$start] . '-' .
$dayStrs[$end];
		}
	}

	return implode(',', $daylistStrings);

}
Compiled Harp