php 文件夹里有多少,计算目录php中有多少个文件
生活随笔
收集整理的这篇文章主要介绍了
php 文件夹里有多少,计算目录php中有多少个文件
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
我正在做一个新项目。我想知道如何制作它,以便计算某个目录中有多少个文件。
$dir = opendir('uploads/'); # This is the directory it will count from
$i = 0; # Integer starts at 0 before counting
# While false is not equal to the filedirectory
while (false !== ($file = readdir($dir))) {
if (!in_array($file, array('.', '..') and !is_dir($file)) $i++;
}
echo "There were $i files"; # Prints out how many were in the directory
?>
这是我到目前为止(从搜索中获得的)。但是它显示不正确吗?我添加了一些注释,以便随时删除它们,它们是为了使我能尽我所能。
如果您需要更多信息,或者觉得我还没有足够描述,请随时声明。
总结
以上是生活随笔为你收集整理的php 文件夹里有多少,计算目录php中有多少个文件的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: java string转bytebuf,
- 下一篇: php ajax 时间戳,获取时间戳 和