Skip to content
Advertisement

Partition array into multiple arrays, by hours

I have a PHP array like this : Pastebin Array Exemple

Each array element have a key TIME. I would like to split this array by hours.

Example :

  • Each array elements with key TIME between 8h – 8h59 = 1 Array

  • Each array elements with key TIME between 9h – 9h59 = 1 Array

  • Each array elements with key TIME between 10h – 10h59 = 1 Array

  • ETC …

And this for all hours in a day.

Could you help me with this please.

EDITED:

Now i have this that is working but i would like to have something much simple.

JavaScript

Advertisement

Answer

Simpler than what you have would be

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement