PHP读取目录下所有文件的代码 _爱资料
主页 > 编程资料 > PHP >
发布时间:2015-12-29 作者:网络 阅读:178次
读取目录下所有文件的代码,可以不管文件名
复制代码 代码如下:
$dir = "file";  

// Open a known directory, and proceed to read its contents  
if (is_dir($dir)) {  
   if ($dh = opendir($dir)) {  

       while (($file = readdir($dh)) !== false) {  
       if ($file!="." && $file!="..") {  
       echo "".$file."
";  
       }  
       }  
       closedir($dh);  
   }  
}  
?> 
关键字词: