How to find fast the number of files in directory?
<p>I have thousands log files in a few directories in my system. Mostly I need to know just number of these files in directory. I fear that this attitude:</p>

<pre><code>$files = count(scandir("logs")) - 2;
</code></pre>

<p>Is not very effective (memory, filesystem). I am considering some global counter (incremented after file is added), unless there is some other effective way?</p>
