<div id="head">
<?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>
2 に答える
0
代わりに使用glob
します:
$i = count(glob('uploads/*')) - count(glob('uploads/*', GLOB_ONLYDIR));
于 2013-08-09T06:51:24.933 に答える