Premise: I'm working at a project that needs to be PHP 5.2 compliant, I cannot use PHP 5.3+ DateInterval or other PHP>=5.3-only instructions, regrettably.
I have an array that contains business hours expressed as $k => $v ranges, so the key is a start, the value is an end, like so:
array( 
    09:00 => 11:30
    09:30 => 11:00
    10:00 => 12:30
    13:30 => 14:30   
)
In this example we have the first three pairs of ranges that overlap, I could express the same thing as 09:00 => 12:30 (meaning: opens at 9 am, closes at 12.30 pm), since the start and end of the first three pairs overlap.
I could also write the array like so, as integers (or I could use floats e.g. 09:30 becomes 9.3 it doesn't matter I think):
array( 
     900 => 1130
     930 => 1100
    1000 => 1230
    1330 => 1430   
)
How to turn the array into:
array(
     900 => 1230
    1330 => 1430
)
Ideas that come to my mind are looping the array, using array_slice, passing values by reference and unset() things while at it... But I'm not sure if that would be the best idea or I'm just overcomplicating it.
 
     
     
    