PHP simple calendar implementation code. Copy the code as follows :? Php $ monthonedaydate (Ym). 01; $ oneweekdaydate (w, strtotime ($ monthoneday); get $ monthdaydate (t) of the week of January 1, 1st day of this month; and $ sta
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...
The http://www.bkjia.com/PHPjc/320737.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/320737.htmlTechArticle code is as follows :? Php $ monthoneday = date ("Ym "). "01"; $ oneweekday = date ("w", strtotime ($ monthoneday); // Get the monthday of the week of January 1, 1st day of this month = date ("t "); // how many days of the month $ sta...