Hello,
I have a question how to solve a problem in PHP.
Goal is to create an array, that includes all data for all weekdays, separated by 30 minutes.
Some data is fetched from a SQL database into an array, that looks like that.
Array
(
[0] => Array
(
[timekey] => 2020-08-06 01:00:00
[0] => 2020-08-06 01:00:00
[count] => 1
[1] => 1
[day] => Monday
[2] => Monday
)
[1] => Array
(
[timekey] => 2020-08-06 01:30:00
[0] => 2020-08-06 01:30:00
[count] => 1
[1] => 1
[day] => Monday
[2] => Monday
)
.
.
.
So I need to add the missing values for the timestamps that are not part of the SQL result
In this example
Array
(
[0] => Array
(
[timekey] => 2020-08-06 00:00:00
[0] => 2020-08-06 00:00:00
[count] => 0
[1] => 0
[day] => Monday
[2] => Monday
)
[1] => Array
(
[timekey] => 2020-08-06 00:30:00
[0] => 2020-08-06 00:30:00
[count] => 0
[1] => 0
[day] => Monday
[2] => Monday
)
.
.
.
At the end of the day I must have an array for Monday to Sunday, separated with all times in 30 minutes sequence.
I hope this was clear.
Does anybody have a hint how I can solve this problem?
Thank you very much
Tobi
What I have tried:
Try to create the complete array for all weekdays and timestamps with count = 0 and doe aaray search for the values from the database