Home >php教程 >PHP源码 >php简单的数组递归

php简单的数组递归

PHP中文网
PHP中文网Original
2016-05-25 17:10:561071browse

php代码

function a($arr){
	if(!is_array($arr)){
		echo $arr."\n";
	}else
	foreach($arr as $v){
		if(is_array($v)){
			foreach($v as $vv){
				echo a($vv)."\n";
			}
		}else{
			echo $v."\n";
		}
	}
}
$a=array("dasfd",array("aaa","bbb"),3,4,array("mickelfeng123",array(34,"mickelfeng","mickelfenghello")));
a($a);
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