當前位置:才華齋>計算機>php語言>

php遞迴遍歷多維陣列的方法

php語言 閱讀(2.58W)

文章主要介紹了php遞迴遍歷多維陣列的方法,例項分析了php陣列遍歷的相關技巧,具有一定參考借鑑價值,需要的`朋友可以參考下.

php遞迴遍歷多維陣列的方法

本文例項講述了php遞迴遍歷多維陣列的方法。分享給大家供大家參考。具體如下:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

<?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);

?>

希望本文所述對大家的php程式設計有所幫助。