Home > Web Front-end > JS Tutorial > PHP displays the file where the current file is located and all files in the folder are expanded in a tree shape_javascript skills

PHP displays the file where the current file is located and all files in the folder are expanded in a tree shape_javascript skills

WBOY
Release: 2016-05-16 17:09:12
Original
1813 people have browsed it
复制代码 代码如下:


$path = "./";
function createDir($path = '.')
{
if ($handle = opendir($path))
{
echo "
    ";
    while (false !== ($file = readdir($handle)))
    {
    if (is_dir($path.$file) && $file != '.' && $file !='..')
    printSubDir($file, $path, $queue);
    else if ($file != '.' && $file !='..')
    $queue[] = $file;
    }
    printQueue($queue, $path);
    echo "
";
}
}
function printQueue($queue, $path)
{
foreach ($queue as $file)
{
printFile($file, $path);
}
}
function printFile($file, $path)
{
echo "
  • $file
  • ";
    }
    function printSubDir($dir, $path)
    {
    echo "
  • $dir";
    createDir($path.$dir."/");
    echo "
  • ";
    }
    createDir($path);
    ?>

    Related labels:
    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