I have 2 range of numbers:
$startTime to $endTime$offerStartTime to $offerEndTime
You need to test if the start of your smaller range is greater or equal to your larger range's start AND if your end of your smaller range is less than or equal to the end of your larger range:
In this case 10-20 falls within 5-25, so returns true. If you don't want to include the endpoints of the range simply change <= and >= to < and > respectively.
10, 'end' => 20];
$outerRange = ['start' => 5, 'end' => 25];
echo isInRange($innerRange,$outerRange);
function isInRange($innerRange,$outerRange) {
if ($innerRange['start'] >= $outerRange['start'] && $innerRange['end'] <= $outerRange['end'] ) {
return true;
}
return false;
}
?>