>  기사  >  백엔드 개발  >  php显示当前文件所在的文件以及文件夹所有文件,树形展开_PHP教程

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

WBOY
WBOY원래의
2016-07-13 17:18:45676검색

  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...
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
이전 기사:php二维数组排序方法(array_multisort usort)_PHP教程다음 기사:php的扩展和嵌入--c扩展开发helloworld_PHP教程

관련 기사

더보기