Home > Backend Development > PHP Tutorial > PHP读取目录下所有文件的代码_php实例

PHP读取目录下所有文件的代码_php实例

WBOY
Release: 2016-06-07 17:26:41
Original
892 people have browsed it

读取目录下所有文件的代码,可以不管文件名

复制代码 代码如下:

$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);  
   }  
}  
?> 
Related labels:
php
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