For special offers and annoucements, please enter your email address below.
The following snippet creates a list of images that are in a folder using the glob function. Its far easier to use than PHP's scandir and allows you read all items of a certain file type within a specified directory. Please note that you need to use a LFS or UNC path or you can use chdir to set the correct directory first.
List of images:<br />
<?php
// Filter out everything except jpeg images.
// Put the results into an array
$images = glob("*.jpg");
//sort the images using PHPs natural sorting algorithm
natsort($images);
//output each of the images
foreach($images as $image){
echo $image."<br />";
echo "<img src='$image' width='200' height='200' /><br /><br /><br />";
}
?>
Here's an example of the code above: