dongyipa0028 2016-11-09 14:20
浏览 15

PHP检查值是否在数组值内

I am using PHP to check, if start time and end time are within array start time and end time.Then do not show those time stamps. Something like this.

while ($row = mysql_fetch_assoc($getReservationSettings)) {
  if((strtotime($res_date) >=strtotime($row['start_date'])) && $row['recur_end_date'] == '0000-00-00')
    {
       if((17:00 <=$row['start_time']) || 17:00 >=$row['end_time'])
           {
               $myarray[]=date("H:i:s",strtotime($time)+$i*$secs);
           }
     } 
}

What is happening here is that in the first loop if start time is 17:15 and end time is 18:00, it is not showing time within that range. But if in 2nd loop the start time is 13:15 and end time is 15:00, then it will show times within the first loop. Basically I have to validate it through each loop. Please help me on this. Thanks

  • 写回答

1条回答 默认 最新

  • doutao6380 2016-11-09 17:35
    关注

    Make an array of start and end time and then find your desired datetime through in_array php function.

    For instance:

    <?php 
    $time= array("17:00", "18:00", "19:00", "20:00");
    if (in_array("18:00", $time))
    {
    echo "Match found";
    }
    else
    {
    echo "Match not found";
    }
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。