Reputation: 11
Hi guys this is my code:
$Months = array(
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec'
);
foreach($Months as $value){
echo "$value ";
echo date('Y');
echo "<br>";
foreach(range(1,31) as $Days) {
echo $Days;
echo " ";
}
echo "<br>";
}
and this is the output:
Jan 2017
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Feb 2017
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
and so on.
How can I edit the index to output the following months and it's days.
Upvotes: 1
Views: 60
Reputation: 155
foreach($Months as $key=>$value){
echo "$value ";
echo date('Y');
echo "<br>";
$year = 2017;
echo implode(" ", range(1, cal_days_in_month(CAL_GREGORIAN, $key+1, $year)));
echo "<br>";
}
Upvotes: 4