here is my code so far:
<?php
//year and month
function getMondays($year) {
$newyear = $year;
$week = 0;
$day = 0;
//month in this case december
$mo = 12;
$mondays = array();
$i = 1;
//whilst numerical day of the week is not equal to 1 which is the monday
//purpose of the loop is to get the current date and set the $day to the first monday
while ($week != 1) {
//keep incrementing by 1 until you hit a monday
$day++;
//december 30th is a wednesday so it falls under the 3rd day of the week
$week = date("w", mktime(0, 0, 0, $mo,$day, $year));
echo $week.'<br>';
}
//pushes the date found onto the end of the array
array_push($mondays,date("r", mktime(0, 0, 0, $mo,$day, $year)));
return $mondays;
}
I can so far get it to get the first monday in the month, however I am pretty confused on how to get the rest of the mondays in a month, and then sticking that onto an array called $mondays;
All help appreciated.