I came across this block of code which pulls images from a folder specified and outputs them with the img
tag:
<?php
$url = "./images/";
$handle = opendir ($url);
while (false !== ($file = readdir($handle))) {
if($file != "." && $file != ".." && $file != basename(__FILE__)) {
echo '<a href="'.$url.$file.'" class="lightbox" title="'.$file.'"><img src="'.$url.$file.'" alt="" /></a><br />';
?>
This works great, but the only thing I am having issues with is the ordering of the images.
So, let's say in my images
folder, I have these images:
2.jpg
b.jpg
a.jpg
1.jpg
How can I make it so that it lists the images in numeric and alphabetical order? I would like the numbered images to come first then the alphabets, so it would list the images like this:
1.jpg
2.jpg
a.jpg
b.jpg