<?php
//万年历
//第一个参数 这个月有多少天
//这个月的1号是星期几
function wannianli($days,$startday){
if($days<1||$days>31){
echo "days 不能大于31 或者小于1";
exit;
}
//Monday、Tuesday、Wednesday、Thursday、Friday、Saturday、Sunday。”
if($startday<0 ||$startday>6){
echo "startday 只能是 0-6 的整数";
exit;
}
$str1="<tr>".str_repeat("<td></td>",$startday);
$str2="";
for($i=1;$i<=7-$startday;$i++){
$str2.="<td>{$i}</td>";
}
$str1.=$str2;
$str1.="</tr>";
$str3="";
for($j=7-$startday+1;$j<$days;$j+=7){
$j0=$j>$days?"":$j;
$j1=$j+1>$days?"":$j+1;
$j2=$j+2>$days?"":$j+2;
$j3=$j+3>$days?"":$j+3;
$j4=$j+4>$days?"":$j+4;
$j5=$j+5>$days?"":$j+5;
$j6=$j+6>$days?"":$j+6;
$str3.="<tr><td>".($j)."</td><td>".($j1)."</td><td>".($j2)."</td><td>".($j3)."</td><td>".($j4)."</td><td>".($j5)."</td><td>".($j6)."</td></tr>";
}
echo "<table width='800' border='1' cellpading=0><tr><th>Monday</th><th>Tuesday</th><th>Wednesday</th><th>Thursday</th><th>Friday</th><th>Saturday</th><th>Sunday</th></tr>";
echo $str1.$str3;
echo "</table>";
}
wannianli(28,0);
?>
联系客服