Home  >  Article  >  php教程  >  php多维数组转一维数组

php多维数组转一维数组

PHP中文网
PHP中文网Original
2016-05-23 16:38:422012browse

php代码

 function arrToOne($multi) 
{
	 $arr = array();
	 foreach ($multi as $key => $val) {
	  if( is_array($val) ) {
	   $arr = array_merge($arr, arrToOne($val));
	  } else {
	   $arr[] = $val;
	  }
	 }
	 return $arr;
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP SQL 查询封装Next article:磁力链接打包下载