I'm working with an array of undefined arrays, where each array (child) has another grouping of indefinite schedules (with start and end time) for the execution of a given task, in the example below there are only two groupings of schedules for each child array, but within the execution of the system there can be several for both the number of schedules and the number of tasks.
The problem is ... How can I check if these times match in a "simpler" way without having to abuse recursion and loop repetitions? because in this system no task can be executed while another is running.
No timetable can be repeated, nor can it start in the time period of another set of times (start time and end time), and if there is at least one matching time, the check may stop.
The rule between times is similar to a "human" "professional", which logically can not be in two places at the same time.
Basically the scan should stop when: ($horario_inicial_atual >= $horario_inicial_anterior OR $horario_inicial_atual <= $horario_final_anterior) AND ($horario_final_atual >= $horario_inicial_anterior || $horario_final_atual <= $horario_final_anterior)
array(2) {
[0]=>
array(2) {
[0]=>
array(2) {
["initial"]=>
string(5) "08:00"
["final"]=>
string(5) "12:00"
}
[1]=>
array(2) {
["initial"]=>
string(5) "14:00"
["final"]=>
string(5) "18:00"
}
}
[1]=>
array(2) {
[0]=>
array(2) {
["initial"]=>
string(5) "08:00"
["final"]=>
string(5) "12:00"
}
[1]=>
array(2) {
["initial"]=>
string(5) "14:00"
["final"]=>
string(5) "18:00"
}
}
}
Note: If this previous list is too complicated to work for this check, this format can also be used:
array(4) {
[0]=>
array(2) {
["initial"]=>
string(5) "08:00"
["final"]=>
string(5) "12:00"
}
[1]=>
array(2) {
["initial"]=>
string(5) "14:00"
["final"]=>
string(5) "18:00"
}
[2]=>
array(2) {
["initial"]=>
string(5) "08:00"
["final"]=>
string(5) "12:00"
}
[3]=>
array(2) {
["initial"]=>
string(5) "14:00"
["final"]=>
string(5) "18:00"
}
}
Note 2: If you can not escape loops, what would be the best practice?
Note 3: I can modify the array in any way, because it is only for verification, then it is discarded.
Note 4: I just need to know if there are coincident times, without even more details, the important thing is to know if it is true or false.