Home > php教程 > php手册 > body text

用php获取文件夹内文件的数量

WBOY
Release: 2016-06-06 19:46:39
Original
3031 people have browsed it

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 用php获取指定文件夹内文件的数量: 用PHP读取一个文件夹内有多少个文件,例如有一个Picture文件夹,里面有200张图片,下面的函数可以得到他的总数是200. ?php $dir = './picture'; $handle = opendi

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

  用php获取指定文件夹内文件的数量:

  用PHP读取一个文件夹内有多少个文件,例如有一个Picture文件夹,里面有200张图片,下面的函数可以得到他的总数是200.

  

  $dir = './picture';

  $handle = opendir($dir);

  $i = 0;

  while(false !== $file=(readdir($handle))){

  if($file !== '.' || $file != ''){

  $i ;

  }

  }

  closedir($handle);

  echo $i;

  ?>

用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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!