1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > php 文件夹里有多少 计算目录php中有多少个文件

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

时间:2019-01-01 20:52:01

相关推荐

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

?>

这是我到目前为止(从搜索中获得的)。但是它显示不正确吗?我添加了一些注释,以便随时删除它们,它们是为了使我能尽我所能。

如果您需要更多信息,或者觉得我还没有足够描述,请随时声明。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。