Home  >  Article  >  Backend Development  >  PHP simple calendar implementation code_PHP tutorial

PHP simple calendar implementation code_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:43:25800browse

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...

www.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...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn