Home > Backend Development > PHP Tutorial > 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
Release: 2016-07-13 09:56:51
Original
978 people have browsed it

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;>
Copy after login

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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template