I have it working, but regardless of how many files there are in the folder, this script always misses 1! So if there's 5, it returns 4...
<?php
function CheckExt($filename, $ext) {
$passed = FALSE;
$testExt = "\.".$ext."$";
if (eregi($testExt, $filename)) {
$passed = TRUE;
}
return $passed;
}
//Define an array of common extensions.
$exts = array("gif","jpg$|\\.jpeg","png","bmp");
//echo "<b>Images in this folder:</b>";
$dir = opendir("$id/lowRes/");
$files = readdir($dir);
while (false !== ($files = readdir($dir))) {
foreach ($exts as $value) {
if (CheckExt($files, $value)) {
echo "<img src=\"$id/lowRes/$files\" alt=\"\" class=\"img\"/>";
$count++; //Keep track of the total number of files.
break; //No need to keep looping if we've got a match.
}
}
}
echo $count." image(s) found in this directory.\n";
closedir($dir);
?>
Any ideas?