我有一个日期范围的数组,就像这样:
[0] => Array
(
[start_time] => 2011-10-01 00:00:00
[end_time] => 2011-10-05 00:00:00
[name] => Apples
)
[1] => Array
(
[start_time] => 2011-10-04 00:00:00
[end_time] => 2011-10-10 00:23:00
[name] => Oranges
)
[2] => Array
(
[start_time] => 2011-10-15 00:00:00
[end_time] => 2011-10-20 00:23:00
[name] => Bananas
)
我正在尝试计算每个事件之间的重叠部分,并将该重叠部分拆分成数组中的独立项目,然后相应地调整相交事件的起始时间和结束时间,使它们不再重叠。例如,在上面的数组中,“苹果”与“橙子”相交一天,因此我希望最终得到一个看起来像这样的数组。
[0] => Array
(
[start_time] => 2011-10-01 00:00:00
[end_time] => 2011-10-04 00:00:00
[name] => Apples
)
[1] => Array
(
[start_time] => 2011-10-04 00:00:00
[end_time] => 2011-10-05 00:00:00
[name] => Apples Oranges
)
[2] => Array
(
[start_time] => 2011-10-05 00:00:00
[end_time] => 2011-10-10 00:23:00
[name] => Oranges
)
[3] => Array
(
[start_time] => 2011-10-15 00:00:00
[end_time] => 2011-10-20 00:23:00
[name] => Bananas
)