You could do this many different ways.
Using date() and mktime() functions"
$numDaysInMonth = date("t", mktime(0, 0, 0, $month, 1, $year));
echo $numDaysInMonth;
There is also a builit in function for calculating the days in any month, also in any calendar:
cal_days_in_month
echo cal_days_in_month (0, 3, 2003);
//this will print 31
// because there are 31 days in the month of March in the year 2003
Also here is a link to PHP calendar functions:
http://www.php.net/manual/en/ref.calendar.php