PHP: Most efficient way to get the number of files within a directory
<p>Consider these two folder structures:</p>

<pre><code>Foo/
    Folder1/
        File1.txt
    Folder2/
    Folder3/
    File2.txt

Bar/
    Folder1/
        Folder2/
    Folder3/
    Folder4/
</code></pre>

<p>I'd like to know the most efficient way in PHP to tell me that the "Foo" folder has two files in it and that the "Bar" folder has zero files in it. Notice that it's recursive. Even though the "File1.txt" file is not <em>immediately</em> inside the "Foo" folder, I still want it to count. Also, I don't care what the names of the files are. I just want the total number of files.</p>

<p>Any help would be appreciated. Thanks!</p>
