我得到了这样的数组:
Array ( [0] => 2020-11-21 [1] => 2020-11-22 [2] => 2020-11-23 )
Array ( [0] => 2020-10-11 [1] => 2020-10-12 [2] => 2020-10-13 [3] => 2020-10-14 [4] => 2020-10-15 )
想要将两个数组合并到一个数组中
预期结果:
Array ( [0] => 2020-11-21 [1] => 2020-11-22 [2] => 2020-11-23 [3] => 2020-10-11 [4] => 2020-10-12 [5] => 2020-10-13 [6] => 2020-10-14 [7] => 2020-10-15 )
我试过 array_merge 像:
public function method($format = 'Y-m-d') {
$arrayObject = $this->context->value('event_date');
$interval = new DateInterval('P1D');
$realEnd = new DateTime($arrayObject['end']);
$realEnd->add($interval);
$period = new DatePeriod(new DateTime($arrayObject['start']), $interval, $realEnd);
foreach($period as $date) {
$array[] = $date->format($format);
}
if (!is_array($array)) {
return FALSE;
}
$result = array();
$a = [];
array_push($a, $array);
foreach ($a as $key => $value) {
// print_r($value);
if (is_array($value)) {
$result = array_merge($result, array_flatten($value));
}
}
//return ;
print_r($result);
}
得到输出是:
Array ( [0] => 2020-11-21 [1] => 2020-11-22 [2] => 2020-11-23 ) Array ( [0] => 2020-10-11 [1] => 2020-10-12 [2] => 2020-10-13 [3] => 2020-10-14 [4] => 2020-10-15 )
请帮我在单个数组中得到结果。