How to traverse a multidimensional array in php
Most people do not understand the knowledge points of this article "how to traverse a multi-dimensional array in php", so the editor summarizes the following, detailed contents, clear steps, and a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to traverse a multi-dimensional array in php" article.
1. Concept
A multidimensional array is an array that contains one or more arrays.
A multidimensional array of two, three, four, or five or more levels.
A two-digit array requires two indexes to select elements.
A three-dimensional array requires three indexes to select elements.
two。 Be careful
(1) No matter how complex the array is, the outermost array array () must be followed by a semicolon!
(2) if there are several juxtaposed elements at the same level, all elements must be added a comma at the end except for the last element of the array.
3. Traversing an instance
Function arr_fun ($arr) {if (is_array ($arr)) {foreach ($arr as $v) {if (is_array ($v)) {arr_fun ($v);} else {echo $v. "
";} else {echo $arr."
";}} above is the content of this article on" how to traverse multidimensional arrays in php ". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please follow the industry information channel.