A few days ago need a perpetual calendar function, on the Oso saw a perpetual calendar, program function to is strong, but too cumbersome.
Do not have their own requirements, so they wrote one, you can also add a connection to the date!
function Calendar ($year, $moon) {
$moon 1=array ("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12");
$moon 2=array ("31", "28", "31", "30", "31", "30", "31", "31", "30", "31", "30", "31");
if (($year -2000)%4==0) {$moon 2[1]=29;}
for ($i =0; $i <=11; $i + +) {
if ($moon 1[$i]== $moon) {
$total = $moon 2[$i];
}
}
$out _chat= "";
$out _chat.= "Day 123456";
for ($i =1; $i <= $total; $i + +) {
$j = $i;
if ($i <10) {
$j = "0". $i;
}
$time _array=getdate (Mktime (0,0,0, $moon, $j, $year));
if ($i ==1) {
Switch ($time _array[wday]) {
Case "0":
$out _chat.= "". $i. "";
Break
Case "1":
$out _chat.= "". $i. "";
Break
Case "2":
$out _chat.= "". $i. "";
Break
Case "3":
$out _chat.= "". $i. "";
Break
Case "4":
$out _chat.= "". $i. "";
Break
Case "5":
$out _chat.= "". $i. "";
Break
Case "6":
$out _chat.= "". $i. "";
Break
}
}else{
if ($i! = $total) {
if ($time _array[wday]!=0) {
$out _chat.= "". $i. "";
}else{
$out _chat.= "". $i. "";
}
}elseif ($i = = $total) {
Switch ($time _array[wday]) {
Case "0":
$out _chat.= "". $i. " ";
Break
Case "1":
$out _chat.= "". $i. " ";
Break
Case "2":
$out _chat.= "". $i. " ";
Break
Case "3":
$out _chat.= "". $i. " ";
Break
Case "4":
$out _chat.= "". $i. " ";
Break
Case "5":
$out _chat.= "". $i. " ";
Break
Case "6":
$out _chat.= "". $i. "";
Break
}
}
}
}
$out _chat.= "";
return $out _chat;
}
$year = 2000;
$moon = 08;
$test =calendar ($year, $moon);
Echo $test;
?>
http://www.bkjia.com/PHPjc/532214.html www.bkjia.com true http://www.bkjia.com/PHPjc/532214.html techarticle //A few days ago need a perpetual calendar function, on the Oso saw a perpetual calendar, program function to is strong, but too cumbersome. Do not have their own requirements, so I wrote a, can also ...