Hi there, I have this php gallery and I need to sort pictures alphabetically. How can I do that? Thank you.
<?php
$dir = htmlspecialchars($_GET["dir"]);
$className = htmlspecialchars($_GET["className"]);
if ($handle = opendir($dir)) {
echo "<div class='photogallery $className'><ul>";
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != ".." && preg_match('/(jpg)|(JPG)$/', $entry) == 1) {
$path = $dir."/".$entry;
$pathThumb = $dir."/thumbs/".$entry;
echo "
<li>
<a href='/$path' data-lightbox='gallery1' data-title=''><img src='/$pathThumb' alt=''></a>
</li>";
}
}
closedir($handle);
echo "</ul><div class='both'></div></div>";
}
?>