/**
- * Author: GuoWangYunYan
- * QQ: 279861795
- * Date: 2011-6-23
- * Link: www.jbuxe.com
- */
- // Set the encoding
- Header ('content-type: text/html; charset = utf-8 ');
- // Abnormal, a five-dimensional array is used.
- $ A = array (
- 'Aaaaa' => array (
- 'Aaaaa' => array (
- '123 ',
- '123 ',
- '123'
- ),
- 'Bbbbbbbb' => array (
- '123 ',
- '123 ',
- '123'
- ),
- 'Cccccccc' => array (
- '123 ',
- '123 ',
- '123'
- ),
- ),
- 'Bbbbbbbb' => array (
- 'Aaaaa' => array (
- '123 ',
- '123 ',
- '123'
- ),
- 'Bbbbbbbb' => array (
- '123 ',
- '123 ',
- '123'
- ),
- 'Cccccccc' => array (
- '123 ',
- '123 ',
- '123'
- ),
- ),
- 'Cccccccc' => array (
- 'Aaaaa' => array (
- '123 ',
- '123 ',
- '123'
- ),
- 'Bbbbbbbb' => array (
- '123 ',
- '123 ',
- '123'
- ),
- 'Cccccccc' => array (
- '000000' => array ('44', '55', '66 '),
- '000000' => array ('44', '55', '66 '),
- '20140901' => array (
- '44' => array ('77 ', '88', '99 '),
- '55' => array ('77 ', '88', '99 '),
- '66 '=> array ('77', '88 ', '99 '),
- ),
- ),
- ),
- );
// Execute the function
- Fun ($ );
-
- // The infinite classification recursion method starts.
- Function fun ($ _ info, $ deep = 0 ){
- // Determine if it is an array
- If (is_array ($ _ info )){
- // Foreach loop
- Foreach ($ _ info as $ key => $ val ){
- // Before the first time-no more than four additional output key names in each loop
- Echo str_repeat ('-', $ deep). $ key .'
';
- // Recursive output key value. By the way, four values are added each time ----
- Fun ($ val, $ deep + 4 );
- }
- } Else {
- // Return directly if the key value is not an array
- Echo str_repeat ('-', $ deep). "$ val
";
- }
- }
- ?>
Recursive interpretation: as an algorithm, recursion is widely used in programming languages. it refers to the re-import phenomenon generated when a function, process, or subprogram calls itself directly or indirectly during operation. Recursion is an important concept in computer science. the recursive method is an effective method in programming. writing a program using recursion can make the program concise and clear. If recursion is not used, the execution efficiency is relatively low. |