This article mainly introduces the use of recursive algorithm of PHP infinite Traversal array, combined with examples of PHP for one-dimensional arrays, two-dimensional arrays and multi-dimensional irregular array of general traversal techniques, the need for friends can refer to the next
Specific as follows:
<?php//Infinite Traversal Array $a1 = Array ("A", "B", "C"); One-dimensional array $a2 = Array (Array (3, 6), Array ("A", "B", "C")); Two-dimensional array $a3 = Array (Array (5, 4, 444), 2, 7, 6, 8, Array ("W", "D", Array (3, 2, "a"), "s")); Multidimensional Irregular array function fun ($a) { foreach ($a as $val) { if (Is_array ($val)) {///If the key value is an array, the function recursively calls Fun ($val); } else {//If the key value is numeric, output echo "$val <br/>"; }//end if }//end foreach }//end fun//fun ($a 1);//fun ($ A2); Fun ($a 3);? >
Output:
55544442768wd32as
The above is the whole content of this article, I hope that everyone's study has helped.