Home > php教程 > php手册 > body text

递归列出所有文件和目录

WBOY
Release: 2016-06-13 12:46:28
Original
806 people have browsed it


/*我的程序在国外的SREVER上,自己编的程序存放到哪,我很难记清。
所以编了一个简单的目录递归函数,查看我的程序,很方便的。
*/
function tree($directory)
{
$mydir=dir($directory);
echo "


    ";
    while($file=$mydir->read()){
    if((is_dir("$directory/$file")) AND ($file!=".") AND ($file!=".."))
    {echo "
  • $file

  • ";
    tree("$directory/$file");
    }
    else
    echo "
  • $file

  • ";
    }
    echo "

";
$mydir->close();
}
//start the program
echo "

目录为粉红色


";
tree(".");
?>
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template