homepage Welcome to WebmasterWorld Guest from 54.166.110.222
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Changing directory read order
wavesurf




msg:1306292
 11:55 am on Nov 26, 2003 (gmt 0)

I have made a small file management utility, but I still have a small design problem. When I read through the directory I get the folders and files in a mixed order since it is read by the time and date they were added, when I would like to get the folders first, and then the files.

Does anyone know if this can be done. I think I can probably get it done, by having one routine just reading all the folders in the directory, and then one routine reading all the files, but I was wondering if there was an easier way, or a smarter way :)

Thanks for any help thrown my way.

 

NickCoons




msg:1306293
 3:51 pm on Nov 26, 2003 (gmt 0)

How do you want to sort them? Are you wanting to put directories ahead of files, and then alphabetically within those two groups?

It depends on which platform you're using and how directories are designated. On *nix, there is a "d" in the attributes column that can be used to seperate directories from files. On Windows, these are designated by "<DIR>".

Seperate your values into two arrays, directories and files. Then you can create a function and use usort() to sort them.

mogwai




msg:1306294
 3:56 pm on Nov 26, 2003 (gmt 0)

Have you looked at the user comments on the directory functions pages on php.net? I haven't looked but this sounds like the kind of thing somebody may have posted there.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved