I had this question to, luckily, now I have an awnser.
$dir=opendir("/usr/home/public_html");
while ($file2 = readdir($dir)) {
echo "$file2";
}
closedir($dir);
Also, if you want to search for all .gif files, do this:
$dir=opendir("/usr/home/public_html");
while ($file2 = readdir($dir)) {
if (substr($file2,-4)==".gif"){
echo "$file2";
}
}
closedir($dir);
Hope that helps!