>  기사  >  백엔드 개발  >  php 读取目录文件夹列表的例子

php 读取目录文件夹列表的例子

WBOY
WBOY원래의
2016-07-25 08:55:591008검색
  1. /**

  2. * 读取目录列表的函数
  3. * edit: bbs.it-home.org
  4. */
  5. function GetFolders( $resourceType, $currentFolder )
  6. {
  7. // Map the virtual path to the local server path.
  8. $sServerDir = ServerMapFolder( $resourceType, $currentFolder, 'GetFolders' ) ;
  9. // Array that will hold the folders names.

  10. $aFolders = array() ;
  11. $oCurrentFolder = opendir( $sServerDir ) ;

  12. while ( $sFile = readdir( $oCurrentFolder ) )

  13. {
  14. if ( $sFile != '.' && $sFile != '..' && is_dir( $sServerDir . $sFile ) )
  15. $aFolders[] = '' ;
  16. }
  17. closedir( $oCurrentFolder ) ;

  18. // Open the "Folders" node.

  19. echo "" ;
  20. natcasesort( $aFolders ) ;

  21. foreach ( $aFolders as $sFolder )
  22. echo $sFolder ;
  23. // Close the "Folders" node.

  24. echo "
  25. " ;
  26. }
复制代码


성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.