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 时间戳,获取时间戳 和