My school wants me (the school's webmaster) to put in some sort of counter that would show the proper day in our 4-day school cycle. It doesn't have to be anything fancy; just a simple script that shows "Today is Day 1", etc.
The trick seems to be to get it to follow a calendar, as you wouldn't want the day of the school cycle to change on Sat.'s and Sun.'s.
I've done tons of Google searches and I can't find anything even closely related to what I'm looking for.
If anyone has any ideas and/or some good tutorials I could look at, I would be extremely grateful!
<?php
$day = date('l'); /* get todays day */
$days=array('Monday','Tuesday','Wednesday','Thursday'); /* set array containing your 4 days */
$i=0;
/* if today's day is a school day, echo it out */
for ($i = 1; $i <= 3; $i++) {
if($days[$i] == $day) {
echo 'Today is ' . $days[$i] . ' This is day ' . $i+=1;
}
/* echos Today is Thursday. This is day 4. */
}
?>
<?php
$day = date('l'); /* get todays day */
$days=array('Monday','Tuesday','Wednesday','Thursday'); /* set array containing your 4 days */
$i=0;
/* if today's day is a school day, echo it out */
for ($i = 1; $i <= 3; $i++) {
if($days[$i] == $day) {
echo 'Today is ' . $days[$i] . ' This is day ' . $i+=1;
}
/* echos Today is Thursday. This is day 4. */
}
?>
else can you elaborate on "proper day"
First: thank you very much for the code.
Second: you're pretty close to what I need, please allow me to elaborate.
Our school operates on a 4-day school cycle. What this means is that on the first day of school, we begin on "Day 1". The kids refer to their class schedule and see where to go for their classes on Day 1. The next day is "Day 2". Again,the kids' classes are the same, but in a different order. Then,"Day 3", same thing, and then "Day 4", same thing again. After Day 4, the cycle starts again on Day 1, and continues in an endless loop until the school year is done.
Of course, there are no school "days" on weekends and statutory holidays (Canadian). For example: today just happens to be Day 4, tomorrow will be Day 1, but Monday is Thanksgiving in Canada, so there is no school and therefore no school "day". On Tuesday, the school "day" will be Day 2.
So, I need a piece of code I can put on our website's home page to indicate the "day" of the school cycle, but I need that code not to count weekends at the very least. If it can't cope with holidays, that's fine, I can deal with that and make changes as needed.
which you might find interesting, the function supplied returns the number of business days (Mon-Fri) between two dates, and takes a third parameter of an array (holidays), which would allow you to exclude national holidays in the result.
for 01/01/2009 to 31/12/2009 including 2 holidays, there are 240 business days.
240/4=60
60 sets of 4.
I imagine you will need some form of database to keep track of the dates, I briefly tried with a text file but just got tied up in knots.
i highly doubt that will work and it's horrendously complicated for what i expect has a very easy solution. and i've just confused myself reading it back
I'm out of ideas, hopefully I've given you at least some help.
Thanks so much for your efforts; this gives me the bare bones of what I need, so I will work on it from here. If I manage to get it up and running, I'll post the results back here.
Thanks again for your efforts, they are very appreciated!!