递归合并数组
使用的函数: array_push() array_merge()
public function upExcel()
{
$arr = array(
[0 => "today" ],
[0 => "is", 1 => "vary", 2 =>[0 => "warm"] ],
[0 => "i123s", 1 => "va231ry", 2 =>[0 => "warm", 1 => [0 => '1213', 1 => '455']] ],
);
dump($this->dealData($arr););
}
/**
* 递归思想
* @param array $input
* @param string $id
*/
public function dealData(array $input)
{
$output = array();
echo 1;
if (is_array($input)){
foreach ($input as $item) {
if (is_array($item)) {
echo 2;
$output = array_merge($output, $this->dealData($item));
echo 3;
} else {
array_push($output, $item);
}
}
} else {
array_push($output, $input);
}
echo 4;
return $output;
}