I can't think of a really easy way to do this. But here are two methods:
Method A) use PHP directory commands:
1) call the dir() function to create a dir object.
2) use readdir to enumerate all the filenames into an array
3) get size of array
The above would work nicely, but I think speed may be a problem (which I doubt)
Method 😎 if you run on UNIX/Linux, use the wc command to get number of lines.
e.g.
$dir = "/wwwroot/myfiles/";
$output = ls -1 $dir | wc;
This will give you a string like this:
46 46 671
The first # is the number of lines (which is the number of files). The second and third #s are number of words and # of characters, respectively. So you don't need these.
my suggestion: if you can't find another way to do this, try both my methods and see which one executes faster. I think the wc command will work faster since you don't need to do extra work in PHP by creating arrays and objects.
hope this helps!
-sridhar