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?

Source: Internet
Author: User
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

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.