This is what I do:
function listdir($strDir, $strPatternMatch=NULL, $strPatternIgnore=NULL, $bIgnorehidden=TRUE)
{
$arResult = NULL;
if (is_dir($strDir))
{
if ($hDir = opendir($strDir))
{
while (false !== ( $strFilename = readdir($hDir) ))
{
if ($bIgnorehidden) if (preg_match("/^[.]/i", $strFilename)) continue;
if (!empty($strPatternMatch)) if (!preg_match($strPatternMatch, $strFilename)) continue;
if (!empty($strPatternIgnore)) if (preg_match($strPatternIgnore, $strFilename)) continue;
$arResult[$strFilename] = $strFilename;
}
closedir($hDir);
}
}
return ($arResult);
}
So in your case you might do:
$arPicFiles = $this->listdir("/site", "/[.]jpg\$|[.]gif\$/i", NULL, TRUE);