-
Sort read directory with PHP
I have a PHP script that uses opendir() and readdir().
I use a while loop to display the results as a list. This works fine on my localhost but not on my web server (displays them in a random order).
Is there any function I can use to sort the results of the while statement (Alphabetically)?
-
-
In the while loop, place the current file in an array (let's call it the files[] array). After the while loop, you can use sort or ksort and echo each item in the array using a foreach loop.
Hope this helps.
-
The Following User Says Thank You to thetestingsite For This Useful Post:
-
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks