在项目开发过程中,有时候可以需要对给定文件夹路径中的文件、图像、zip文件、rar文件等进行计数,那么我们就可以使用php中的glob()和count()函数进行计数。
代码示例如下:
<?php
$folderPath = "upload/";
$countFile = 0;
$totalFiles = glob($folderPath . "*");
if ($totalFiles){
$countFile = count($totalFiles);
}
print_r($countFile);
相关函数介绍:
glob()函数寻找与模式匹配的...