php读取目录文件夹列表的例子
时间:2021-07-01 10:21:17
帮助过:30人阅读
/** - * 读取目录列表的函数
- * edit: bbs.it-home.org
- */
- function GetFolders( $resourceType, $currentFolder )
- {
- // Map the virtual path to the local server path.
- $sServerDir = ServerMapFolder( $resourceType, $currentFolder, 'GetFolders' ) ;
// Array that will hold the folders names. - $aFolders = array() ;
$oCurrentFolder = opendir( $sServerDir ) ; while ( $sFile = readdir( $oCurrentFolder ) ) - {
- if ( $sFile != '.' && $sFile != '..' && is_dir( $sServerDir . $sFile ) )
- $aFolders[] = '' ;
- }
closedir( $oCurrentFolder ) ; // Open the "Folders" node. - echo "" ;
natcasesort( $aFolders ) ; - foreach ( $aFolders as $sFolder )
- echo $sFolder ;
// Close the "Folders" node. - echo "
" ; - }
|