欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程语言 > php >内容正文

php

php 文件夹里有多少,计算目录php中有多少个文件

发布时间:2025/3/21 php 35 豆豆
生活随笔 收集整理的这篇文章主要介绍了 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中有多少个文件的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。