too long

Possible Duplicate:
PHP iterate days of month given month and year

How can I calculate number of days in each month for a given year?

To do this I created a function as below:

// Calculate number of days in each month for a given year.
function getDays($year){

    $num_of_days = array();
    $total_month = 12;
    if($year == date('Y'))
        $total_month = date('m');
    else
        $total_month = 12;

    for($m=1; $m<=$total_month; $m++){
        $num_of_days[$m] = cal_days_in_month(CAL_GREGORIAN, $m, $year);
    }

    return $num_of_days;
}
$num_of_days = getDays('2011');
print_r($num_of_days);

read this cal_days_in_month

Return the number of days in a month for a given year and calendar