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

www.phpzy.comtrue/php/14618.htmlTechArticlePHP判断数组是一维二维或几维 //可以判断是一维的,还是二维的,或是几维的数组: function getmaxdim($arr){ if(!is_array($arr)){ return 0; }else{ $dimension = 0; foreach($arr as $item1) { $t1=$this-getmaxdim($item1);...

相关文章

    暂无相关文章
相关频道:

PHP之友评论

今天推荐