Posted By

coggla on 01/20/08


Tagged

images directory opendir


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

mbcdg
uisluu


Scan for Images


 / Published in: PHP
 

Function to retrieve all image files in a given directory

  1. function listImages($dirname=".") {
  2. $ext = array("jpg", "png", "jpeg", "gif");
  3. $files = array();
  4. if($handle = opendir($dirname)) {
  5. while(false !== ($file = readdir($handle)))
  6. for($i=0;$i<sizeof($ext);$i++)
  7. if(strstr($file, ".".$ext[$i]))
  8. $files[] = $file;
  9.  
  10. closedir($handle);
  11. }
  12. return($files);
  13. }

Report this snippet  

You need to login to post a comment.