Home > Backend Development > PHP Tutorial > Click the Active name again, and I have expanded your function. Hehe, now you can list the files on the entire disk in a tree structure. _PHP Tutorial

Click the Active name again, and I have expanded your function. Hehe, now you can list the files on the entire disk in a tree structure. _PHP Tutorial

WBOY
Release: 2016-07-13 16:58:00
Original
748 people have browsed it

Rewrite your function into a recursive function. Now this function can list all files in a specified directory and files in subdirectories.
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 )?("".$entry):("".$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);
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631452.htmlTechArticleRewrite your function into a recursive function. Now this function can list all files and subtitles in a specified directory The files in the directory. ? function listdir($path) { chdir($path); $d = d...
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