时间:2021-07-01 10:21:17 帮助过:14人阅读
function getmaxdim($arr){
if(!is_array($arr)){
return 0;
}else{
$dimension = 0;
foreach($arr as $item1)
{
$t1=$this->getmaxdim($item1);
if($t1>$dimension){$dimension = $t1;}
}
return $dimension+1;
}
}
//验证过可以使用.
//测试
$arr=array('yiyi'=>1212,'haha'=>array('heihei'=>array(array("a")),"b"));
echo getmaxdim($arr);
//结果 4
http://www.bkjia.com/PHPjc/762029.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/762029.htmlTechArticle//可以判断是一维的,还是二维的,或是几维的数组: function getmaxdim($arr){ if(!is_array($arr)){ return 0; }else{ $dimension = 0; foreach($arr as $item1) { $t1=$thi...