TechniqueUse the natsort() function: <?php $files = array("file001.txt", "file002.txt", "file003.txt", "file010.txt", "file023.txt", "file004.txt"); natsort($files); foreach ($files as $file) { print "$file\n"; } ?> CommentsThe natsort() function uses a sorting algorithm that is described by Martin Pool at http://www.linuxcare.com.au/projects/natsort/. A case-insensitive version of the natsort() function is also available, natcasesort() . |