本文實例講述了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程序設計有所幫助。