有沒有一種有效的方法來計算文件夾裏面有更多文件和子文件夾的文件?如何使用PHP計算文件夾和子文件夾內的文件
我試過這樣的事情,仍然沒有給我正確的數字。 Windows會識別Images文件夾中有159個文件。當我只得到144
<?php
$img = count(glob("./assets/images/*.*"));
$about = count(glob("./assets/images/aboutus/*.*"));
$blog1 = count(glob("./assets/images/blog/*.*"));
$mason = count(glob("./assets/images/blog/masonary/*.*"));
$tl = count(glob("./assets/images/blog/timeline/*.*"));
$blog2 = count(glob("./assets/images/blogdetails/*.*"));
$gallery = count(glob("./assets/images/gallery/*.*"));
$home = count(glob("./assets/images/home/*.*"));
$keg = count(glob("./assets/images/kegiatan/*.*"));
$port1 = count(glob("./assets/images/portfolio/*.*"));
$port2 = count(glob("./assets/images/portfolio-details/*.*"));
$srv = count(glob("./assets/images/services/*.*"));
$usr = count(glob("./assets/images/users/*.*"));
$count = $img+$about+$blog1+$mason+$tl+$blog2+$gallery+$home+$keg+$port1+$port2+$srv+$usr;
?>
幫助??
編輯: 完成。我的錯。我沒有統計某些文件夾中的子文件夾。
但是,還有一種方法可以縮短它嗎?
隨着'recursivedirectoryiterator'可能? –
如果有什麼幫助你,你應該回答這個問題。或者回答你自己的問題 – SuperDJ
我還是沒有得到它 –