您好,欢迎访问一九零五行业门户网

PHP判断数组是一维二维或几维_PHP教程

//可以判断是一维的,还是二维的,或是几维的数组:
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...
其它类似信息

推荐信息