php自定义函数:递归把多维数组转为一维数组
时间:2021-07-01 10:21:17
帮助过:18人阅读
function array_multi2single($array) - {
- static $result_array=array();
- foreach($array as $value)
- {
- if(is_array($value))
- {
- array_multi2single($value);
- }
- else
- $result_array[]=$value;
- }
- return $result_array;
- }
//测试 - $array=array("1"=>array("A","B","C",array("D","E")),"2"=>array("F","G","H","I"));
- $array=array_multi2single($array);
- echo "
测试结果:"; - foreach($array as $value)
- {
- echo "
$value"; - echo "
"; - }
- ?>
|