I have been baffled by this problem with PHP for about a day now. Basically, we have an array of clocks formatted in a 24-hour format, and an arbitrary value ( $hour) (also a 24-hour clock). The problem is that we need to take $hourand get the next available value in the array, starting with the value that continues immediately $hour.
An array might look something like this:
$goodHours = array('8,9,10,11,12,19,20,21).
Then the hour value can be:
$hour = 14;
So we need a way to find out that 19 is the best, best time. In addition, we may also need to obtain a second, third or fourth (etc.) available value.
The problem is that since 14 is not a value in the array, there is no index for the link that allows us to increment to the next value.
To make things easier, I took $goodHoursand repeated the values several times so that I did not have to deal with a return to the beginning (maybe this is not the best way to do this, but a quick solution).
I have a feeling that it’s just that I’m missing, but I would be so grateful if anyone could shed some light.
Eric
source
share