<?php /*________________________________________________________________


lixlpixel PHParadise

_______________________________________________________________________

category :		image handling

snippet :		list image folder

downloaded :	02.09.2009 - 08:02

file URL :		http://www.fundisom.com/phparadise/php/image_handling/list_image_folder

description :	this snippet reads a given directory and returns an array of the images found. gets some information about the images as well .

drop this in any directory and replace the path to the folder with ./ and specify the files you want to show.
you get a list of all files which mach the criteria.

___________________________START___COPYING___HERE__________________*/ ?>


<?php

$imgdir = 'galleryimage/'; // the directory, where your images are stored
$allowed_types = array('png','jpg','jpeg','gif'); // list of filetypes you want to show

$dimg = opendir($imgdir);
while($imgfile = readdir($dimg))
{
 if(in_array(strtolower(substr($imgfile,-3)),$allowed_types))
 {
  $a_img[] = $imgfile;
  sort($a_img);
  reset ($a_img);
 } 
}

$totimg = count($a_img); // total image number
 
for($x=0; $x < $totimg; $x++)
{
 $size = getimagesize($imgdir.'/'.$a_img[$x]);

 // do whatever
 $halfwidth = ceil($size[0]/2);
 $halfheight = ceil($size[1]/2);
 echo 'name: '.$a_img[$x].' width: '.$size[0].' height: '.$size[1].'<br />';
}

?>


<?php /*_____________________END___OF___THE___CODE______________________


get more code from http://www.fundisom.com/phparadise/


___________________________________________________________________*/ ?>