<?
function m_d($v,$d) {
$d = array(31,31,28,31,30,31,30,31,31,30,31,30,31);
$t = split("\ ",$v);
if($t[1] == $d[$t[0]] && $d>0) {
$t[0]++;
$t[1] = 1;
}else if($t[1] == 1 && $d<0) {
$t[0]--;
$t[1] = $d[$t[0]];
if($t[0] == 0) $t[0] = 12;
}else
$t[1] .= $d;
return sprintf("%02d %02d",$t[0],$t[1]);
}
function foo($ar) {
static $p = 0;
$retval = false;
if($p == 0) {
$p = $ar['end_dt'];
return $retval;
}
if($p < $ar['start_dt'])
$retval = array('start_dt' => m_d($p,1), 'end_dt' => m_d($ar['start_dt'],-1) );
$p = $ar['end_dt'];
return $retval;
}
$a=array();
$a[0]['start_dt']="9 25";
$a[0]['end_dt']="10 05";
$a[1]['start_dt']="10 15";
$a[1]['end_dt']="10 30";
$a[2]['end_dt']="10 20";
$a[2]['end_dt']="11 20";
foreach($a as $v) {
if($r = foo($v))
$ar[] = $r;
}
print_r($ar);
?>