Hi,
I'm fairly new to php and as a project I've decided to try (😃) and follow a guide to making a PHP calendar (over at devarticles. I've been getting on ok, referring to php.net to see what the different functions do but this piece of code has stumped me - I really dont undersand how it works:
for($i = 1; $i < $numDays+1; $i++, $counter++)
{
$timeStamp = strtotime("$year-$month-$i");
if($i == 1)
{
// Workout when the first day of the month is
$firstDay = date("w", $timeStamp);
for($j = 0; $j < $firstDay; $j++, $counter++)
echo "<td> </td>";
}
It might just be a matter of me looking more carefully but could someone attempt to explain what its achieving . Have a look at this if my question makes no sense what so ever 😛
Table headings for the days of the week start at Sunday and end at Saturday, however each different month could start on a different day, so we have to setup empty cells to push the 1st day of the month under its appropriate day
O_o
Cheers, and happy xmas to you all 😃
Henry