Call us Toll-Free:
1-800-218-1525
Live ChatEmail us

 Sponsors

count images in dir

Code Wizard, 12-30-2006

This script counts how many .gif/.jpg's etc. are in a certain dir. ENJOY! btw, this should work for anything actually, lol.

<?
$imgcount = "/dir/to/images";
$type = "jpg"; //can be anything: gif, jpg, bmp, etc
$dirpath = "$imgcount";

$chm = 0;
$dhm = dir($DOCUMENT_ROOT . "$dirpath");
while ($entry = $dhm -> read()) {
if (strrchr($entry,'.') == ".$type") {
$chm += 1;
}
}
$dhm -> close();

echo "Total Images: $chm<br>";
?>
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions