I need to check multiple date ranges to see if they have a same day more than 3 times
<p>Okay, so I have a start datetime and an end datetime for multiple items. I need to find out if there are more than 3 items that are within the same datetime as each other. I just can't wrap my head around this one, I can get the days of each individual item into an array using this function</p>

<pre><code>function getDatesBetween2Dates($startTime, $endTime) {
$day = 86400;
$format = 'm/d/y g:i A';
$startTime = strtotime($startTime);
$endTime = strtotime($endTime);
$numDays = round(($endTime - $startTime) / $day) + 1;
$days = array();
for ($i = 0; $i &lt; $numDays; $i++) {
    $days[] = date($format, ($startTime + ($i * $day)));
}
return $days;
}
</code></pre>

<p>The problem is, it only get the first time and just adds a full day to every day afterward. it doesn't take into account for the last days time. I just can't think of an efficient way to do this.</p>

<p>Just to clarify, let me give you an example. I have 5 items in my table, they each have a datetime range.. start and end. I need to check if 4 or more of those items have any days in their date range that are the same. Can anyone point me in the right direction? Thanks.</p>
