We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

luman on 08/06/06


Tagged

image array


Versions (?)


Who likes this?

14 people have marked this snippet as a favorite

shamrog12
guerrera
damarev
mediahackers
blakeb
mmmattos
fael
hudge
JimiJay
Morgano
Baris
ibomb
oriolfb
mrjthethird


read images of directory


Published in: PHP 


URL: http://superpixel.ch/projects/imageload/

  1. $folder = opendir("."); // Use 'opendir(".")' if the PHP file is in the same folder as your images. Or set a relative path 'opendir("../path/to/folder")'.
  2.  
  3. $pic_types = array("jpg", "jpeg", "gif", "png");
  4.  
  5. $index = array();
  6.  
  7. while ($file = readdir ($folder)) {
  8.  
  9. if(in_array(substr(strtolower($file), strrpos($file,".") + 1),$pic_types))
  10. {
  11. array_push($index,$file);
  12. }
  13. }
  14.  
  15. closedir($folder);

Report this snippet 

You need to login to post a comment.