Hello Guys I have the following problem:
I have in an array the records of the attendance schedules that are the following:
array(8) {
[0]=>
string(8) "11:13:09"
[1]=>
string(8) "13:06:12"
[2]=>
string(8) "13:28:05"
[3]=>
string(8) "09:59:59"
[4]=>
string(8) "13:14:27"
[5]=>
string(8) "13:34:58"
[6]=>
string(8) "14:32:20"
[7]=>
string(8) "14:33:38"
...
How can I add them and accumulate them with their respective schedule in the following switch:
switch ($horas) {
case ($$horas >= '08:00:00') && ($$horas <= '09:00:00'):
break;
case ($$horas >= '09:00:00') && ($$horas <= '10:00:00'):
break;
case ($$horas >= '10:00:00') && ($$horas <= '11:00:00'):
break;
case ($$horas >= '11:00:00') && ($$horas <= '12:00:00'):
break;
case ($horas >= '12:00:00') && ($horas <= '13:00:00'):
break;
case ($horas >= '13:00:00') && ($horas <= '14:00:00'):
break;
case ($horas >= '14:00:00') && ($horas <= '15:00:00'):
break;
case ($horas >= '15:00:00') && ($horas <= '16:00:00'):
break;
case ($horas >= '16:00:00') && ($horas <= '17:00:00'):
break;
case ($horas >= '17:00:00') && ($horas <= '18:00:00'):
break;
case ($horas >= '18:00:00') && ($horas<= '19:00:00'):
break;
case ($horas>= '19:00:00') && ($horas<= '20:00:00'):
break;
case ($horas>= '20:00:00') && ($horas <= '21:00:00'):
break;
case ($horas >= '21:00:00:') && ($horas <= '22:00:00'):
break;
}
The is not necessary
switch
, an array whose index is the initial time is enough, assuming ranges of one hour for each time entry. So you limit yourself to inserting elements for each schedule based on the hour, that is, discarding minutes and seconds. The rest is just to give a suitable format to the resulting array, for example withprintf()
:Result: