Home >php教程 >php手册 >Multidimensional array to one-dimensional array

Multidimensional array to one-dimensional array

WBOY
WBOYOriginal
2016-11-19 13:05:231274browse

Code to facilitate some data processing
​​<br> //Multiple dimensions become one dimension<br> function arr_foreach ($arr)<br> {<br>         static $tmp=array(); <br> If (!is_array ($arr))<br>           {<br>                                                                                                                                                                                                   return  false;       }<br> foreach ($arr as $val)<br>           {<br>             if (is_array ($val))<br>                                      {<br>                arr_foreach ($val);<br>          }<br>          else<br>                                       {<br>                $tmp[]=$val;<br>          }<br>       }<br>                                                                                                                                       return }<br> <br>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn