如何检查时间之间的时间数组在php


how to check if time is in between the time array in php?

谁能告诉我怎么做?

我有两个声明数组和一个变量…

$check_start = array('5:00', '11:00');
$check_finish = array('8:00', '15:00');
$time =  "7:00";

我有一个循环来检查$time是否在两个数组之间

foreach($check_start as $key => $value)
{   
    $newTime = date('h:i', strtotime($time));
    $timeStart = date('h:i', strtotime($value));
    $timeFinish = date('h:i', strtotime($check_finish[$key]));
    if($newTime > $timeStart && $newTime < $timeFinish) {                       
        echo "inBetween";
    }else {
        echo "not";
    }
}

,输出为

inBetween not

现在我只想显示一个输出:如果数组之间至少有一个。

then display only "inbetween".

echo "inBetween";
break;
  $pass= 0;
foreach($check_start as $key => $value)
{   
$newTime = date('h:i', strtotime($time));
$timeStart = date('h:i', strtotime($value));
$timeFinish = date('h:i', strtotime($check_finish[$key]));
  if($newTime > $timeStart && $newTime < $timeFinish) {                       
   $pass++;
  }
}
if ($pass > 0){echo 'inbetween';}