Home  >  Article  >  Web Front-end  >  php显示当前文件所在的文件以及文件夹所有文件以树形展开_javascript技巧

php显示当前文件所在的文件以及文件夹所有文件以树形展开_javascript技巧

WBOY
WBOYOriginal
2016-05-16 17:09:121664browse
复制代码 代码如下:


$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