Home >php教程 >php手册 >目录递归循环php代码

目录递归循环php代码

WBOY
WBOYOriginal
2016-05-25 16:56:38995browse
这是一款从代码和速度上还不错的php目录遍历代码,有需要的朋友可以参考一下。
 代码如下 复制代码

$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));



Statement:
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