How to use PHP to return a count of images in a directory?

csin

New Member
I have a Javascript object like this:\[quote\]\[code\]var count = { table:19, people:39, places_details:84, story_1:18, story_2:6, story_3:11 }\[/code\]\[/quote\]Each item (table, people, etc.) is a directory within 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:\[quote\]\[code\]ar count = { table: <?php count(dir("table")) ?>, people: <?php count(dir("people")) ?>, places_details: <?php count(dir("places_details")) ?>, story_1: <?php count(dir("story_1")) ?>, story_2: <?php count(dir("story_2")) ?>, story_3:<?php count(dir("story_3")) ?> }\[/code\]\[/quote\]But need to filter for JPG and return a number. What's the right code?
 
Back
Top