Home  >  Article  >  Backend Development  >  How to traverse multi-dimensional arrays recursively in php, recursive multi-dimensional arrays in php_PHP tutorial

How to traverse multi-dimensional arrays recursively in php, recursive multi-dimensional arrays in php_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:56:51966browse

How to recursively traverse multi-dimensional arrays in php, php recursive multi-dimensional arrays

This article describes the method of recursively traversing multi-dimensional arrays in php. Share it with everyone for your reference. The details are as follows:

<&#63;php
function get_array_elems($arrResult, $where="array"){
 while(list($key,$value)=each($arrResult)){
    if (is_array($value)){
      get_array_elems($value, $where."[$key]");
    }
    else {
      for ($i=0; $i<count($value);$i++){
      echo $where."[$key]=".$value."<BR>\n";
      }
    }
 }
}
 get_array_elems($arrResult);
&#63;>

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/986074.htmlTechArticleHow to recursively traverse multi-dimensional arrays in php, php recursive multi-dimensional arrays. This article describes the method of recursively traversing multi-dimensional arrays in php. Share it with everyone for your reference. The details are as follows: phpfunctio...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn