Prova cosi':
output:Codice PHP:function days_in_month($month, $year) {
$start = date('Y-m-d', mktime(0, 0, 0, $month, 1, $year));
$end = date('Y-m-t', strtotime($start));
$current = $start;
$days = array();
while ($current <= $end) {
$weekday = date('D', strtotime($current));
if (!isset($days[$weekday])) {
$days[$weekday] = 0;
}
$days[$weekday]++;
$current = date('Y-m-d', strtotime("{$current} +1 day"));
}
return $days;
}
$days = days_in_month(4, 2015);
print_r($days);
codice:Array ( [Wed] => 5 [Thu] => 5 [Fri] => 4 [Sat] => 4 [Sun] => 4 [Mon] => 4 [Tue] => 4 )

Rispondi quotando