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
WBOYOriginal
2016-05-16 17:09:121841browse
复制代码 代码如下:


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

    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