Jump to content

php readdir ... order??


nikefido

Recommended Posts

The manual says that they are returned in the order that they are stored in the filesystem, which could be just about anything

 

 

http://us.php.net/readdir

 

You could read all of your filenames into an array and then sort the array with one of PHP's many array sorting functions

 

http://us3.php.net/manual/en/function.sort.php

Link to comment
https://forums.phpfreaks.com/topic/102932-php-readdir-order/#findComment-527285
Share on other sites

If you just want the list of contents, use scandir(). It will sort it alphabetically in ascending order by default, or with an optional flag set, in descending order.

 

Thanks I'll check this out. Right now it's using the directory helper found in the Code Igniter framework - which luckily is very easy to extend and hack. I'll try messing with it to get a file list in alphabetical order.

 

Thanks for the tips.

 

Please keep them coming if anyone has any other thoughts

Link to comment
https://forums.phpfreaks.com/topic/102932-php-readdir-order/#findComment-527323
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.