這篇文章主要介紹了php遞歸遍歷多維數組的方法,實例分析了php數組遍歷的相關技巧,具有一定參考借鑒價值,需要的朋友可以參考下
本文實例講述了php遞歸遍歷多維數組的方法。分享給大家供大家參考。具體如下:
- <?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程序設計有所幫助。
新聞熱點
疑難解答