Home > php教程 > php手册 > 再点一次Active的名,我把你的函数功能扩充了一下,嘻嘻,现在能以树型结构列出整个磁盘上的文件啦。

再点一次Active的名,我把你的函数功能扩充了一下,嘻嘻,现在能以树型结构列出整个磁盘上的文件啦。

WBOY
Release: 2016-06-13 10:02:46
Original
955 people have browsed it

把你的函数改写成递归函数,现在这个函数可以列出某指定目录内的所有文件及子目录内的文件啦。

function listdir($path)
{
     chdir($path);
     $d = dir($path);
     $d->path."
";
     print "

    ";
         while($entry=$d->read()){
            if ($entry"." and $entry".." ){
           $last=filemtime($entry);
           print "
  • ";
           $name=is_dir($entry)?("再点一次Active的名,我把你的函数功能扩充了一下,嘻嘻,现在能以树型结构列出整个磁盘上的文件啦。".$entry):("再点一次Active的名,我把你的函数功能扩充了一下,嘻嘻,现在能以树型结构列出整个磁盘上的文件啦。".$entry);
           print $name." --- ".date("Y/m/d h:i:s",$last);
           if (is_dir($path."/".$entry)){
               listdir($path."/".$entry);
           }
            }
        }
         $d->close();
         print "
";
}
$listpath="c:";
echo $listpath;
listdir($listpath);
?>

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