This article mainly introduces php's method of traversing multi-dimensional arrays. It involves php's methods of traversing multi-dimensional arrays and implementing recursive operations. It has some reference value. For more information, see
This article mainly introduces php's method of traversing multi-dimensional arrays. It involves php's methods of traversing multi-dimensional arrays and implementing recursive operations. It has some reference value. For more information, see
$ A = array ('fruits '=> array ('A' => 'Orange', 'B' => 'grape', c => 'apple '), 'numbers '=> array (1, 2, 3, 4, 5, 6), 'calles' => array ('first', 5 => 'second', 'third ')); // Method 1: foreach ($ a as $ list => $ things) {if (is_array ($ things) {foreach ($ things as $ newlist => $ counter) {echo "key :". $ newlist."
"." Value: ". $ counter ."
";}}// Type 2: function MulitarraytoSingle ($ array) {$ temp = array (); if (is_array ($ array )) {foreach ($ array as $ key = >$ value) {if (is_array ($ value) {MulitarraytoSingle ($ value );} else {$ temp [] = $ value ;}}}}