With php, populate an array of days in current month
calendar, php
Solution
You can use this function:
function dates_month($month, $year) {
$num = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$dates_month = array();
for ($i = 1; $i <= $num; $i++) {
$mktime = mktime(0, 0, 0, $month, $i, $year);
$date = date("d-M-Y", $mktime);
$dates_month[$i] = $date;
}
return $dates_month;
}
echo"<pre>";
print_r(dates_month(2, 2012));
echo"</pre>";
Problem
Possible Duplicate: how to generate monthly days with PHP? With PHP, given a month in this format: 10 - October, 11 - November, how would I populate an array where the keys represent each day for the given month. So, e.g for February you'd have an array with keys 1-28.