Home  >  Article  >  Backend Development  >  使用php将某个目录下面的所有文件罗列出来的方法详解_php技巧

使用php将某个目录下面的所有文件罗列出来的方法详解_php技巧

WBOY
WBOYOriginal
2016-05-17 08:59:49908browse
直接给源代码了:
复制代码 代码如下:

$current_dir = 'E:/temp/';
$dir = opendir($current_dir);
echo "direcotry list:
    ";
    while(false !== ($file=readdir($dir))){
     if($file != "." && $file != ".."){
      echo "
  • $file
  • ";
     }
    }
    echo "
";
closedir($dir);

如果跟web是同一个盘符,就直接写:$current_dir='/temp/';就可以了。
Statement:
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