1. Construct a two-level directory with 0 to 90 numbers, each with a 2-digit name such as 00/79 and print out all the directories?
Reply to discussion (solution)
#结果: Array ([0] = + [1] = [2] = [3] = [4] = [5] = [6] = [7] = 07 [8] =& Gt [9] [+] = [ten] = [one] = [all] = [+] = [+] = [+] = [] [[]] T [+] [+] = [+] [+] [+] = [+] [] [] [] [] [] [] [] [] [] [] Gt [+] = [+] = [+] [+] = [+] = [+] = [+] = [+] = [+] = [+] = [+] = [35] =& Gt [[+] = [PNS] = [Notoginseng] [+] [+] [+] [+] [+] = [+] = [+] = [+] = [+] = [[]] [[]] [43] [44] =& Gt [[] [[] [] [[] [] [] [[]] [[+] [] [[]] [[+] = [[]] Gt [[+] [[+]] [[+] [] [[+] [] [+] [+] [+] [+] [+] [+] [+] [+] [+] [+] [+] [+] = [+] = [62] =& Gt [[+] = [+] = [+] [+] [+] [+] [[[]] [[]] [[[]] [[]] [[]] [[] [] [[]] [[+] [] = [[]] [[+] = [Bayi] = Bayi [[+] [+] = [[]] = [+] = [+] = [+] = [] [[[]] [[[]] [[]] [[]] [[]] [[+]] [[]] > [98] = 98 [[+] = 99]
If you have more than two levels, you need to deal with this more.
Recursive directory name, theoretically support infinite level directory, Max is the numeric maximum function loopnames ($level, $max) { static $data; static $name; for ($i = 0; $i <= $max; $i + +) { if ($level > 0) { $name [$level] = sprintf ("%02d", $i); Loopnames ($level-1, $max); } else { $data [] = implode ('/', $name); break; } } return $data;} Set_time_limit (0); $t 1 = Microtime (true), $names = Loopnames (2), Echo Microtime (True)-$t 1;print_r ($names);// Output 10,000/*4.5159900188446array ( [0] = 00/00 [1] = 00/01 [2] = 00/02 [3] = = 00/03< C20/>[4] = 00/04 [5] = 00/05 [6] = 00/06 [7] = = 00/07 [8] = = 00/08 [9] = 00 /09 [Ten] = 00/10 [one] = 00/11 [All] = 00/12 [] = 00/13 [+] = 00/14 [ [] = 00/15 [+] = 00/16 [+] = 00/17 [+] = 00/18 [+] = 00/19...*/
Do you also help others with their homework?
So how did he learn? Just give it a little thought.
What to do if you use mkdir (), give some thought