I have the following code:
$imageDir = "uploads/";
$allowedTypes = array('png', 'jpg', 'jpeg', 'gif');
$dimg = opendir($imageDir);
$images = array();
while ($imgfile = readdir($dimg)) {
if (in_array(strtolower(substr($imgfile, -3)), $allowedTypes) || (in_array(strtolower(substr($imgfile, -4)), $allowedTypes))) {
$images[] = $imgfile;
}
}
Basically what I need is also order the images in the $images array. For example I have image-1.png, image-2.png, image-23.png, image-3.png , I want them stored in the correct order in my $images array (1, 2, 3, 23) not (1, 2, 23, 3).