<?
function f_listDirectory($strLangDir="./")
{
global $file_type,$file_count;

$dirCurrent=dir($strLangDir);
while($strFile=$dirCurrent->read())
{
if(is_dir($strFile) && $strFile!="." && $strFile!="..")
{
chdir($strFile);
f_listDirectory();
chdir("..");
}

if(is_file($strFile)) 
{
$strFile = strtolower($strFile);
$strType=substr($strFile,strrpos($strFile,".")+1);
//是图片?
if(in_array($strType,$file_type))$file_count++;
}
}
$dirCurrent->close();
}$file_path = "/tmp";$file_count = 0;
$file_type = array("jpg","jpeg","bmp","gif");chdir($file_path);
f_listDirectory();echo "图片数目为:$file_count";
?>