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 :)
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.