How to use PHP to return a count of images in a directory?
<p>I have a Javascript object like this:</p>

<blockquote>
<pre><code>var count = {
            table:19,
            people:39,
            places_details:84,
            story_1:18,
            story_2:6,
            story_3:11
            }
</code></pre>
</blockquote>

<p>Each item (table, people, etc.) is a directory <em><strong>within</strong></em> my <code>graphics/</code> directory at the site root. I would like to use PHP to supply the numeric values by counting the JPG images in the corresponding directory. I imagine something like this:</p>

<blockquote>
<pre><code>ar count = {
           table: &lt;?php count(dir("table")) ?&gt;,
           people: &lt;?php count(dir("people")) ?&gt;,
           places_details: &lt;?php count(dir("places_details")) ?&gt;,
           story_1: &lt;?php count(dir("story_1")) ?&gt;,
           story_2: &lt;?php count(dir("story_2")) ?&gt;,
           story_3:&lt;?php count(dir("story_3")) ?&gt;
           }
</code></pre>
</blockquote>

<p>But need to filter for JPG and return a number. What's the right code?</p>
