Have you ever had one of those days when your brain just didn’t leave the first gear?
I have an array containing the start and end time. I would like to create a new array showing the keys of the overlapping entries from the original array. So, let's say we have some “reservations”. Any overlapping “reservations” refer to the same “session”. The initial array is like:
[reservations] => Array ( [1125] => Array ( [start] => 2011-01-07 10:00:00 [end] => 2011-01-07 10:30:00 ) [1244] => Array ( [start] => 2011-01-07 10:15:00 [end] => 2011-01-07 11:30:00 ) [1311] => Array ( [start] => 2011-01-07 11:00:00 [end] => 2011-01-07 11:45:00 ) [1422] => Array ( [start] => 2011-01-07 12:00:00 [end] => 2011-01-07 12:30:00 ) [1561] => Array ( [start] => 2011-01-07 12:30:00 [end] => 2011-01-07 12:45:00 ) [1622] => Array ( [start] => 2011-01-07 13:00:00 [end] => 2011-01-07 13:45:00 ) )
will create a new array, for example:
[sessions] => Array ( [0] => Array ( [0] => 1125 [1] => 1244 [2] => 1311 ) [1] => Array ( [0] => 1422 [1] => 1561 ) [2] => Array ( [0] => 1622 ) )
What would be the most efficient way to do this for large arrays? Thanks!
source share