Return to Snippet

Revision: 16462
at August 5, 2009 05:54 by level09


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

                                

Initial Title
Get Image files in a directory into a array

Initial Tags
php, image, directory

Initial Language
PHP