Home  >  Article  >  Backend Development  >  PHP reads how many files there are in a folder_PHP tutorial

PHP reads how many files there are in a folder_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:35:40880browse

PHP function to read how many files there are in a folder.
For example, if there is a Pic folder with 100 pictures in it, the following function can get the total number of 100

$dir = ./pic;
$handle = opendir($dir);
$i = 0;
while(false !== $file=( readdir($handle))){
if($file !== . || $file != ..){
$i ;
}
}
closedir($handle );
echo $i;
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/508296.htmlTechArticlePHP function to read how many files there are in a folder. For example, there is a Pic folder with 100 files in it. Picture, the following function can get its total number of 100?php $dir = ./pic; $handle = op...
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