Return to Snippet

Revision: 4781
at January 20, 2008 22:20 by coggla


Initial Code
function listImages($dirname=".") {
   $ext = array("jpg", "png", "jpeg", "gif");
   $files = array();
   if($handle = opendir($dirname)) {
       while(false !== ($file = readdir($handle)))
           for($i=0;$i<sizeof($ext);$i++)
               if(strstr($file, ".".$ext[$i]))
                   $files[] = $file;

       closedir($handle);
   }
   return($files);
}

Initial URL

                                

Initial Description
Function to retrieve all image files in a given directory

Initial Title
Scan for Images

Initial Tags
images, directory

Initial Language
PHP