PHP Code:
<?
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");
$dir = opendir("/home/cardesk/public_html/wallpapers/");
$files = readdir($dir);
while (false !== ($files = readdir($dir))) {
foreach ($exts as $value) {
if (CheckExt($files, $value)) {
$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);
?>
Now I have this, doesnt seem to look for subdirectories though, how do I make it do so?