好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

6、PHP列出目录下的文件名

如果你想列出目录下的所有文件,使用以下代码即可:

  1   function  listDirFiles( $DirPath  ){ 
   2  
  3       if ( $dir  =  opendir ( $DirPath  )){ 
   4  
  5            while (( $file  =  readdir ( $dir ))!==  false  ){ 
   6  
  7                   if (! is_dir ( $DirPath . $file  )) 
   8  
  9                   { 
  10  
 11                       echo  "filename:  $file <br >" ; 
  12  
 13                   } 
  14  
 15            } 
  16  
 17       } 
  18  
 19   }
  20  
 21   //  使用方法如下 
 22  
 23  listDirFiles('home/some_folder/');


查看更多关于6、PHP列出目录下的文件名的详细内容...

  阅读:43次