sunslayer commented on a Page, Calendar Class  -  Aug 21, 2012

nice job. but you could simplify your code farther by using cal_days_in_month() to fill an array like this

function Calendar($month, $year)
{   
    $offSet = date("w",mktime(0, 0, 0, $month, 1, $year));

    for($i = 0; $i < $offSet; $i++)
        $cal[] = "";

    for($i = count($cal), $x = 1; $i < cal_days_in_month(CAL_GREGORIAN, $month, $year) + $offSet; $i++, $x++)
        $cal[] = $x;
}

then printing the calendar would just be a matter of creating a new table row after every 7 days

note that this method assumes Sunday to be the first day of the week

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.