i have another question. I have the text files stored in the local document folder. i was able to display the file names in ascending order. but i want to know how to sort it in descending order using php. thanks. i want to give the user the ability to sort the files when they click a button.
Asked
Active
Viewed 2,192 times
-3
-
3just type in your browser address bar: `php sort reverse order`. It is really simple – Your Common Sense Apr 13 '13 at 07:38
-
good god, if i have not thought of that, would i post it here? – freeloader Apr 13 '13 at 07:39
-
I think your question can be solved here: http://stackoverflow.com/questions/884974/sort-and-display-directory-list-alphabetically-using-opendir-in-php – tonylattke Apr 13 '13 at 07:43
1 Answers
1
If your filenames stored within array, you might try this:
array_reverse($filenames)
UPD:
You may use scandir, if they are not:
scandir($path, SCANDIR_SORT_DESCENDING)

BlitZ
- 12,038
- 3
- 49
- 68
-
thanks for the reply. actually the textfiles are not stored in the array that's why i am having trouble sorting them out. i already used that function, to no avail. – freeloader Apr 13 '13 at 07:44
-
1
-
1why don`t you put them to array before output? `scandir($dir, SCANDIR_SORT_DESCENDING)` might help otherwise. – BlitZ Apr 13 '13 at 07:47