php遞歸遍歷多維數組的方法
來源:文萃谷 2.49W
文章主要介紹了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程序設計有所幫助。