$one = array('start' => '2012-10-12', 'stop' => '2012-11-04', 'over' => false);
$two = array('start' => '2012-10-29', 'stop' => '2012-11-14', 'over' => true);
$three = array('start' => '2012-11-12', 'stop' => '2012-12-07', 'over' => false);
$array = array($one, $two, $three);
这告诉我:
Array
(
[0] => Array
(
[start] => 2012-10-12
[stop] => 2012-11-04
[over] =>
)
[1] => Array
(
[start] => 2012-10-29
[stop] => 2012-11-14
[over] => 1
)
[2] => Array
(
[start] => 2012-11-12
[stop] => 2012-12-07
[over] =>
)
)
我想要拆分这些日期的函数。如果 in array is over = true那么这个日期应该分割其他日期。
对于这个例子,这应该返回:
Array
(
[0] => Array //this is changed
(
[start] => 2012-10-12
[stop] => 2012-10-28
[over] =>
)
[1] => Array //this is ok
(
[start] => 2012-10-29
[stop] => 2012-11-14
[over] => 1
)
[2] => Array //this is changed
(
[start] => 2012-11-15
[stop] => 2012-12-07
[over] =>
)
)
第二个例子:
$one = array('start' => '2012-10-12', 'stop' => '2012-12-04', 'over' => false);
$two = array('start' => '2012-10-29', 'stop' => '2012-11-14', 'over' => true);
$second = array($one, $two);
这还给我:
Array
(
[0] => Array
(
[start] => 2012-10-12
[stop] => 2012-12-04
[over] =>
)
[1] => Array
(
[start] => 2012-10-29
[stop] => 2012-11-14
[over] => 1
)
)
我想收到:
Array
(
[0] => Array //this is changed - old [0] date
(
[start] => 2012-10-12
[stop] => 2012-10-28
[over] =>
)
[1] => Array //this is ok
(
[start] => 2012-10-29
[stop] => 2012-11-14
[over] => 1
)
[2] => Array //this is new - from old [0] date - next part
(
[start] => 2012-11-15
[stop] => 2012-12-04
[over] =>
)
)
我怎样才能用 PHP 做到这一点?