Multidimensional Arrays Nested to Unlimited Depth

后端 未结 6 1046
被撕碎了的回忆
被撕碎了的回忆 2020-12-06 07:33

I have a multidimensional array nested to an unknown/unlimited depth. I\'d like to be able to loop through every element. I don\'t want to use, foreach(){foreach(){for

6条回答
  •  心在旅途
    2020-12-06 08:03

    Take a look to the RecursiveIteratorIterator interface.

    $interface = new RecursiveIteratorIterator( new RecursiveArrayIterator($your_array) );
    foreach($interface as $k=>$v) { /* your function*/  }
    

提交回复
热议问题