I have an array with the available schedules, these times being in a 30 minute interval:
$arrHoras = ["08:30", "09:00", "09:30", "10:00", "10:30", ... , "18:30", "19:00"];
After some filters that are reserved times, I have the following array:
$arrHoras = array(
2 => "09:00",
3 => "09:30",
6 => "11:00",
7 => "11:30",
10 => "13:00",
11 => "13:30",
12 => "14:00",
13 => "14:30",
16 => "16:00",
17 => "16:30",
21 => "18:30"
);
What I need is to make one more filter by removing the times that do not satisfy the amount of followed periods needed. They all serve 1 which is himself, but if it's two I need him and one more followed time, being that he can not jump, for example, from 9 to 9:30 ok, but from 9:30 to 11 no , because it skips the sequence.
If I need 2 times then the return would be this:
$arrHoras = array(
2 => "09:00",
6 => "11:00",
10 => "13:00",
11 => "13:30",
12 => "14:00",
16 => "16:00"
);
But if I need 3 times then the return would be this:
$arrHoras = array(
10 => "13:00",
11 => "13:30"
);
And if I need 4 or more times it will return an empty array.