欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP多維數(shù)組遍歷方法(2種實(shí)現(xiàn)方法)

 更新時(shí)間:2015年12月10日 09:59:16   作者:happy664618843  
這篇文章主要介紹了PHP多維數(shù)組遍歷方法,實(shí)例分析了2種多維數(shù)組的遍歷技巧,包括簡(jiǎn)單的foreach遍歷與遞歸操作遍歷實(shí)現(xiàn)方法,需要的朋友可以參考下

本文實(shí)例講述了PHP多維數(shù)組遍歷方法。分享給大家供大家參考,具體如下:

方法一:

$a=array('fruits'=>array('a'=>'orange',
  'b'=>'grape',c=>'apple'),
  'numbers'=>array(1,2,3,4,5,6),
  'holes'=>array('first',5=>'second','third')
  );
foreach($a as $list=>$things){
 if(is_array($things)){
  foreach($things as $newlist=>$counter){
   echo "key:".$newlist."<br/>"."value:".$counter."<br/>";
  }
 }
}

方法二:

function MulitarraytoSingle($array){
  $temp=array();
  if(is_array($array)){
   foreach ($array as $key=>$value )
   {
    if(is_array($value)){
     MulitarraytoSingle($value);
    }
    else{
     $temp[]=$value;
    }
   }
  }
}

希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論