Displaying HTML links to files in alphabetical order?
Hello
I have a script that searches a folder on my server for pdf files then displays links to them on a web page in an unordered list. My questions is... is it possible to change the order that these files are displayed? Eg. alphabeticaly? I can't work out how these files are being displayed by default... it doesn't appear to be by modified date or alphabeticaly?
Any help greatly appreciated!
PHP Code:
<?php
$dom = new DOMDOcument ();
$ul = $dom->appendChild ($dom->createElement ('ul'));
You could simply assign the result of glob() to a variable, then apply the sorting function of preference (e.g. natcasesort()?) to that array, then run your foreach on the sorted array.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
You could simply assign the result of glob() to a variable, then apply the sorting function of preference (e.g. natcasesort()?) to that array, then run your foreach on the sorted array.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks