PHP - sorting an array of filenames with numbers? PHP - sorting an array of filenames with numbers? arrays arrays

PHP - sorting an array of filenames with numbers?


You can use natsort. or natcasesort, which is case insensitive. If there is more than numbers (ie. diacritics), you should assure that you use proper locale.

If it is not enough, ie. you want also sort number literals ("one", "two", "three"), you can use usort, which permits to use your custom callback as comparison function.


Use can get the natural ordering using natsort

See it.