亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

php數(shù)組遍歷類與用法示例

 更新時間:2019年05月24日 14:19:41   作者:a小風(fēng)車  
這篇文章主要介紹了php數(shù)組遍歷類與用法,結(jié)合實(shí)例形式分析了php基于面向?qū)ο蟮臄?shù)組遍歷、讀取操作封裝與使用技巧,需要的朋友可以參考下

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

<?php
  class scanArray{
    public $arr;
    public $where;
    private $str;
    public function scan($arr,$where="array"){
      $this->arr = $arr;
      $this->where = $where;
      foreach($this->arr as $k=>$v){
        if(is_array($v)){
          $this->where = ($this->where)."[{$k}]";
          $this->scan($v,$this->where);
        }else{
          $this->str .= $this->where."[{$k}]=".$v.'<br />';
        }
      }
      return $this->str;
    }
    function __destruct(){
      unset($this->arr);
      unset($this->where);
    }
  }
  $a = array('g'=>"a",'vv'=>array("b"=>"b","l"=>"c","xx"=>array("e","g")));
  $ah = new scanArray();
  $b = $ah->scan($a);
  echo $b;

運(yùn)行結(jié)果:

array[g]=a
array[vv][b]=b
array[vv][l]=c
array[vv][xx][0]=e
array[vv][xx][1]=g

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《PHP數(shù)組(Array)操作技巧大全》、《php排序算法總結(jié)》、《PHP數(shù)據(jù)結(jié)構(gòu)與算法教程》、《php程序設(shè)計(jì)算法總結(jié)》、《php字符串(string)用法總結(jié)》及《PHP常用遍歷算法與技巧總結(jié)

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

相關(guān)文章

最新評論