Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Set your timezone
- $timezone = date_default_timezone_set('UTC');
- //Pull our date in integer form, easy way to search our array.
- //$intDay = date('w',strtotime("Wednesday")); //Test code to change the date
- $intDay = date('w');
- /* Now we need a way to cycle the classes
- ** And maybe the times too, why not?
- ** So lets construct a 2D array storing all the information
- */
- $classArray = array(
- //Monday
- array ( "Class37830"),
- //Tuesday
- array ("Class27800","Class28930"),
- //Wednesday
- array ("Class37830"),
- //Thursday
- array (),
- //Friday
- array ("Class16700","Class17800","Class18900"),
- //Saturday
- array (),
- //Sunday
- array ()
- );
- /* Now we have our data stored in an array count of 7 (for each day of the week) and we have our day
- ** numeric number, ie. 0 = Monday, 1 = tuesday.. 6 = sunday.
- ** we can just do a for loop, check the contents of the 2D array on that date, and if it exisits,
- ** just echo it out
- */
- for ($i = $intDay; $i < $intDay + 7; $i++){
- /*This counter will loop above our array length, but we still want 7 days..
- ** So we set $c to be our indexer for our array to give us the final, correct date value.
- */
- $c = ($i <= 7) ? $i : $i - 7;
- //Check if our day has any classes
- if (!empty($classArray[$c])){
- //It does, so let's alert the user which date it is.
- echo "<b><p>Class for ".date('l', strtotime("Monday +$i days")). "</p></b>";
- //Then cycle the array and print out the class information
- foreach($classArray[$c] as $output){
- echo "<li>".$output."</li>";
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement