So, let us assume that your time format is always hh:mm. You want to check if the time is between 9 and 18 hours. The problem in your code, as you described, comes when you are check again 09:mm. As it strips away the minute part and just compares the hours.
I would try something like this:
elseif ( implode("", explode(":", $data[6])) > 900 && implode("", explode(":", $data[6])) < 1800)
I will explain the approach step by step.
First of all, this code checks if the date is within the range of 09:00 to 18:00. The code you have provided tested if it is less than 9 or more than 18.
Let us focus on one part of the code, that will explain the whole thing as well:
implode("", explode(":", $data[6])) > 900
First, we separate hours and minutes using the explode
function. This gives us an array with two values.
`[0] => hh,`
`[1] => mm`
Now that we have separated this value we implode or concatenate them using the implode
function that has no separator.
Next, instead of testing against the string, we test against the number. 09:00 is the same as 900 in this case.
Thus, we can check if the time is within the required limits.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…