Home  >  Article  >  Backend Development  >  PHP displays the file where the current file is located and all the files in the folder, and expands it in a tree shape_PHP tutorial

PHP displays the file where the current file is located and all the files in the folder, and expands it in a tree shape_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:18:45676browse

  1. $path = "./";
  2. function createDir($path = '.')
  3. {
  4. if ($handle = opendir($path))
  5. {
  6. 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 "
    ";
  7. }
  8. }
  9. function printQueue($queue, $path)
  10. {
  11. foreach ($queue as $file)
  12. {
  13. printFile($file, $path);
  14. }
  15. }
  16. function printFile($file, $path)
  17. {
  18. echo "
  19. $file
  20. ";
  21. }
  22. function printSubDir($dir, $path)
  23. {
  24. echo "
  25. $dir";
  26. createDir($path.$dir."/");
  27. echo "
  28. ";
  29. }
  30. createDir($path);
  31. ?>


原文地址:http://www.freejs.net/article_jquerywenzi_112.html

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/621624.htmlTechArticle$path = "./"; function createDir($path = '.') { if ($handle = opendir($path)) { echo " "; while (false !== ($file = readdir($handle))) { if (is_dir($path.$file) $file != '.' $file...
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
Previous article:PHP two-dimensional array sorting method (array_multisort usort)_PHP tutorialNext article:PHP two-dimensional array sorting method (array_multisort usort)_PHP tutorial

Related articles

See more