I have a situation that I can not wrap my head around at the moment. Multiple Time Overlaps. I’ve seen many posts on two times that overlap but nothing that has multiple times overlapping.
Here’s the data I would like to place in:
<?php
//RUN EACH Class Selection for Monday
foreach($class as $Classes){
$time[] = array($ClassStartTime, $ClassEndTime, $classID);
}
OverLapFunction($time);
?>
Which would then post the classID and Overlapping Amount. Has anyone run into this situation before? Or figured out how to do this?
Say your data is like this:
You just need a nested
foreach, like this:Basically, it compares each class to all classes. If
$class1start time is less than$class2end time and$class1start time is more than$class2start time: they overlap. Keep in mind that each class will be compared to each other twice (e.g.: A to B, B to A), so if it doesn’t match on the first pass, it will in the second.This’ll give you:
If you were to change class
Dto:…effectively overlapping all classes, you’d get: