Php-php Tutorial

Source: Internet
Author: User
Php perfect non-redundant code traversal folder parameter 20 returned directory file 1 returned directory file + Directory 2 returned Directory all files + empty directory (for some 2 types of development, -_-B) 3. return to all files in the directory 4. return to all files in the directory + Directory 5. return to all directories in the directory 6. return to the directory without saying anything. directly run the code functionget_dir ($ a, $ s0, $ darray
Parameter 2
0. return the files in the directory.
1. return the files and directories under the Directory.
2. return all files and empty files in the Directory (for some 2 types of development, the header is not suitable-_-B)
3. return all files in the directory.
4. return all files and directories under the Directory.
5. return to all directories in the directory
6. return to the Directory

Directly add code without saying anything
Function get_dir ($ a, $ s = 0, $ d = array ('. ','.. '), $ f = array () {foreach (scandir ($ a) as $ g) {if (! In_array ($ g, $ d) {$ g = $. '/'. $ g; if ($ s> 0 & is_dir ($ g )) {($ s = 1 | $ s> 3 | ($ s = 2 & count (scandir ($ g) = 2 )) & $ f [] = $ g. '/'; $ s> 1 & $ s <6 & $ f = get_dir ($ g, $ s, $ d, $ f );} else {($ s & $ s <5) | (! $ S & is_file ($ g) & $ f [] = $ g ;};}; return $ f ;}

Bupt_roy

Learn from Daniel

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.