三维数组转二维数组
$data=array ( [0] => Array ( [0] => Array ( [name] => "测试" ) [1] => Array ( [school] => "学校" ) [2] => Array ( [material_id] => 7 ) [3] => Array ( [content] => 2 ) [4] => Array ( [dosage] => 2 ) ) ) /*************** * @function 三维数组转二维数组 * @Param: $data : 传入参数 * @Return: $data 返回结果数组 ***************/ function array3_to_array2($data) { $b = array(); foreach ($data as $v) { $c = array(); foreach ($v as $vv) { $key = array_keys($vv); //获取数组的键 $value = array_values($vv); //获取数组的值 $c[$key[0]] = $value[0]; } $b[] = $c; } return $b; } print_r($b);die; //打印实例 array ( [0] => Array ( [carrier] => 2 [name] => B1(硝酸) [material_id] => 6 [content] => 3 [dosage] => 3.261 ) )