When showing files, sometimes they dont go in order especially if they have numbers in, such as 2.jpg and 20.jpg.
So heres the answer…
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<?php $array1 = array("img12.png", "img10.png", "img2.png", "img1.png"); asort($array1); echo "Standard sorting\n"; print_r($array1); natsort($array1); echo "\nNatural order sorting\n"; print_r($array1); ?> |
You could also have used just sort($array1)