Home > Backend Development > PHP Tutorial > Example of php reading directory folder list

Example of php reading directory folder list

WBOY
Release: 2016-07-25 08:55:59
Original
1058 people have browsed it
  1. /**

  2. * Function to read directory list
  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. }

复制代码


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template