我正在做一个新项目。我想知道如何制作它,以便计算某个目录中有多少个文件。
<div id="header">
<?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
?>
</div>
这是我到目前为止(从搜索中获得的)。但是它显示不正确吗?我添加了一些注释,以便随时删除它们,它们是为了使我能尽我所能。
如果您需要更多信息,或者觉得我还没有足够描述,请随时声明。
拉风的咖菲猫
慕森卡
湖上湖