When I was writing a file system, I took a fancy to a foreign HTML template... there was a calendar on it and I wanted to write it out in PHP...
The code is as follows:
$ Monthoneday = date ("Ym"). "01 ";
$ Oneweekday = date ("w", strtotime ($ monthoneday); // Obtain the day of the week from January 1, 1st day of this month.
$ Monthday = date ("t"); // The number of days of the month
$ Startlow = ($ oneweekday = 0 )? 7: $ oneweekday; // start from column number
For ($ a = 1, $ B = $ startlow; $ a <= $ monthday; $ a ++, $ B ++ ){
$ Ary [$ B] = $ a; // use arrays to control the output of dates.
}
$ C = 1;
// The number of output rows equals to the number of days in the current month, except 7 and then 1
For ($ a = 1; $ a <= (int) ($ monthday/7) + 1; $ a ++ ){
Echo "";
// I use the array key to control where to output the data.
For ($ B = 1; $ B <= 7; $ B ++, $ c ++ ){
If ($ ary [$ c] = date ("j ")){
Echo '';
} Else {
Echo "";
}
Echo $ ary [$ c];
Echo "";
Echo "\ n ";
}
Echo "";
}
?>
It is estimated that the writing method is different from that written by others... I have been writing this program for a long time. at the beginning, there was a problem with the loop idea. I actually output 31 lines and 1234 lines...
It seems that only multi-write can exercise thinking... this should be implemented using JS, but I won't be able to use JS... this is the only thing I can do.
The following figure shows the effect... the template is pretty nice...