You see, it is really an easy job...
I can't teach you how to fly, but to crawl, it is OK!
try to make the data echo into a table then you get what you want. You should try to understand the method I used below...
<?php
define( 'Y', date( 'Y' ) );
define( 'M', date( 'n' ) );
define( 'D', date( 'j' ) );
define( 'MaxD', date( 't' ) ); // number of days in current month.
// we want the know the 1st day of this month is what day in weekend.
// w = numberic representation of the day of week.
$dayA = date( 'w', mktime( 0,0,0,M,1,Y) );
// so we know the 1st of this month starts with 4 (Thursday).
// so in order to loop, we need to know what number to start.
/*
S M T W T F S
0 1 2 3 4 5 6
1
0 1
-1 0 1
-2 -1 0 1
-3 -2 -1 0 1
-4 -3 -2 -1 0 1
-5 -4 -3 -2 -1 0 1
So, if the $dayA is 4 then we should start from -3.
*/
$i = 1 - $dayA;
$nLine = 0;
for( $i; $i<=MaxD; $i++ ) {
echo $i.' ';
if( $nLine < 6 ) {
$nLine++;
} else {
$nLine = 0;
echo '<hr>';
}
}
?>