php多维数组遍历1
作者:互联网
实现方式 一
采用PHP本身自带的迭代器类 RecursiveIteratorIterator
$test_arr = array(1,2,3,array(4,'aa'=>5,6,array(7,'bb'=>8),9,10),11,12); $arrayiter = new RecursiveArrayIterator($test_arr); $iteriter = new RecursiveIteratorIterator($arrayiter); //直接打印即可按照横向顺序打印出来 foreach ($iteriter as $key => $val){ echo $key.'=>'.$val; } //结果 /* 0=>1 1=>2 2=>3 0=>4 aa=>5 2=>6 0=>7 bb=>8 4=>9 5=>10 4=>11 5=>12 */
出处:www.cainiaojc.com/note/qadjbo.html
标签:aa,arr,遍历,RecursiveIteratorIterator,val,test,多维,array,php 来源: https://www.cnblogs.com/bereallyme/p/16387135.html