php|将二维数组转化为一维数组

/** * @param $result 二维数组 * @return array将二维数组转换成一维数组 * */ public function arrForm($result){ $arr = []; if(is_array($result)){ foreach ($result as $key =>$value){ foreach($value as $k => $v){ $arr[$k]=$v; } } } return $arr; }

例:二维数组
Array ( [0] => Array ( [id] => 666 [title] => 测试666 [catid] => 2 [inputtime] => 1551337927 ) )

【php|将二维数组转化为一维数组】转化为
Array ( [id] => 666 [title] => 测试666 [catid] => 2 [inputtime] => 1551337927 )

    推荐阅读