Copy code The code is as follows:
$monthoneday=date("Ym")."01";
$oneweekday=date("w",strtotime($monthoneday)); //Get the day of the week on the 1st of this month
$monthday=date("t"); //How many days in this month
$startlow=($oneweekday==0)?7:$oneweekday; //From which column to start
for($a=1,$b=$startlow;$a<=$monthday;$ a++,$b++){
$ary[$b]=$a; //Use an array to control where the date is output
}
$c=1;
//The number of output rows is equal to the current month Divide the number of days by 7, round up and add 1
for($a=1;$a<=(int)($monthday/7)+1;$a++){
echo "
";
//I use the key of the array to control where it is output
for($b=1;$b<=7;$b++,$c++){
if($ary[$ c]==date("j")){
echo ''; }else{ echo " | "; } echo $ary[$c]; echo " | ";
echo "n";
}
echo "
";
}
?>
The writing method is probably different from other people's writing... Hehe... I wrote this program for a long time. At the beginning, there was always a problem with the circular thinking. It actually output 31 lines and 1234...
It seems Only by writing more can you exercise your thinking... This should be implemented with JS, but I don't know JS... This is the only way.
The following is the effect... mainly the template is very beautiful...
http://www.bkjia.com/PHPjc/320737.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320737.htmlTechArticleCopy the code as follows: ?php $monthoneday=date("Ym")."01"; $oneweekday= date("w",strtotime($monthoneday)); //Get the day of the week on the 1st of this month$monthday=date("t"); //How many days in this month$sta...