I have getting array like:
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 )
Want to combine both arrays in a single array
expected result:
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 )
I have tried array_merge like:
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);
}
getting output is:
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 )
Please help me to get the result in single array.