Test if a range intersects another range of numbers

前端 未结 6 1348
小鲜肉
小鲜肉 2021-01-07 03:41

I have 2 range of numbers:

  • $startTime to $endTime
  • $offerStartTime to $offerEndTime

6条回答
  •  南笙
    南笙 (楼主)
    2021-01-07 04:10

    Hope this will help you out, I have tried this with all your inputs and it is working fine..

    0);
    {
        if(count($set)>1)
        {
            echo "Matched";
        }
        //added this to prevent this case offerStartTime: 1, offerEndTime: 10, 
        //ranges intersection is the endTime
        elseif(count($set)==1)
        {
            if($set[0]!=$startTime)
            {
                echo "Matched";
            }
        }
    }
    

提交回复
热议问题