可以判断是一维的,还是二维的,或是几维的数组:
function getmaxdim($vDim) { if(!is_array($vDim)) return 0; else { $max1 = 0; foreach($vDim as $item1) { $t1 = $this->getmaxdim($item1); if( $t1 > $max1) $max1 = $t1; } return $max1 + 1; } }
验证过可以使用.
#测试 $arr=array('yiyi'=>1212,'haha'=>array('heihei'=>array(array("a")),"b")); echo getmaxdim($arr);
//结果 4
转载于:https://blog.51cto.com/windchaser/1251511