Home > Backend Development > PHP Tutorial > Directory recursive loop php code_PHP tutorial

Directory recursive loop php code_PHP tutorial

WBOY
Release: 2016-07-13 16:55:09
Original
775 people have browsed it

This is a PHP directory traversal code that is good in terms of code and speed. Friends in need can refer to it.

 代码如下 复制代码

$path = '..';
function get_filetree($path){
$tree = array();
foreach(glob($path.'/*') as $single){
if(is_dir($single)){
$tree = array_merge($tree,get_filetree($single));
}
else{
$tree[] = $single;
}
}
return $tree;
}
print_r(get_filetree($path));

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631704.htmlTechArticleThis is a PHP directory traversal code that is pretty good in terms of code and speed. Friends in need can refer to it. . The code is as follows Copy the code $path = '..'; function get_filetree($path){ $t...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template