慕虎7371278
<?php
$year = '2013'; $months = array( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec' ); $days = array( 31,
(strtotime("1 Mar ".$year) - strtotime("1 Feb ".$year)) / ( 24 * 60 * 60 ), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ); $wday = array( '', '', '', '', '', '', '' ); $cal = array(); foreach(range(0, 11) as $i) { $firstday = getdate(strtotime('1 '.$months[$i].' '.$year)); $fromday = $firstday['wday']; $leftday = 7 - ( $fromday + $days[$i] ) % 7; $cal[] = array_merge( array_slice($wday, 0, $fromday), range(1, $days[$i]), array_slice($wday, 0, $leftday)
);
}?><?php foreach(range(0, 11) as $i) : ?><table>
<thead>
<tr><th colspan="7"><?php echo $months[$i].' '.$year; ?></th></tr>
<tr><th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th>
</thead>
<tbody>
<tr>
<?php
foreach($cal[$i] as $k => $v) { if($k && !($k % 7)) echo "</tr><tr>"; echo "<td>{$v}</td>";
} ?>
</tr>
</tbody></table><?php endforeach ?>