-3

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.

freeloader
  • 336
  • 2
  • 6
  • 18

1 Answers1

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
    Then store them in an array, and use it. – Virus721 Apr 13 '13 at 07:47
  • 1
    why don`t you put them to array before output? `scandir($dir, SCANDIR_SORT_DESCENDING)` might help otherwise. – BlitZ Apr 13 '13 at 07:47