I would like to sort the contents of the directory in numerical order. The contents of the directory are images. Right now the image files are displayed randomly. Each time a new image is added to the directory, it displays randomly on the page. Please advise! Thank you!
<?php
// set image directory
$image_dir = "main";
//Open images directory
$dir = @ dir($image_dir);
?>
<?php
//List files in images directory
while (($file = $dir->read()) !== false)
{
// remove dir dots
if ($file !== '.' && $file !== '..') {
// print out images
echo '<img src="'. $image_dir . '/' . $file .'" height="600" alt=""/>';
}
}
$dir->close();
?>