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