This:
elseif($day > 13){
if (in_array($month, $_31)) {
$d=31;
$to_go= $d - $day + 13;
echo $to_go.' days until the 13th.';
} elseif (in_array($month, $_30)){
$d=30;
$to_go= $d - $day + 13;
echo $to_go.' days until the 13th.';
}
can be combined into:
elseif($day>13)
{
$d = (in_array($month, $_31))?31:(in_array($month, $_30))?30:($year==1)?29:28;
// If the month has 31 days, give $d value of 31
// If not, if the month is in the 30 day array, give $d value of 30
// If not, must be Feb. so is it a leap year? If so, set to 29
// Otherwise, set to 28
$to_go = $d-$day+13;
echo $to_go.' days until the 13th.';
}