Posted By

level09 on 08/05/09


Tagged

php image directory scan


Versions (?)

Who likes this?

9 people have marked this snippet as a favorite

vali29
thastyle
irishsk
umang_nine
ReeceMarsland
joethermal
mecha
seanthom2004
tux-world


Get Image files in a directory into a array


 / Published in: PHP
 

  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.