Heim  >  Artikel  >  Backend-Entwicklung  >  php显示当前文件所在的文件以及文件夹所有文件,树形展开_PHP教程

php显示当前文件所在的文件以及文件夹所有文件,树形展开_PHP教程

WBOY
WBOYOriginal
2016-07-13 17:18:45679Durchsuche

  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...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:php二维数组排序方法(array_multisort usort)_PHP教程Nächster Artikel:php的扩展和嵌入--c扩展开发helloworld_PHP教程

In Verbindung stehende Artikel

Mehr sehen