Forum Moderators: coopster

Message Too Old, No Replies

sorting files

         

sampford

8:37 pm on Apr 30, 2005 (gmt 0)

10+ Year Member



i have a small little problem - i am looking for some sort of script, that will allow me to sort out files into order, determined by their filename, eg. 30-04-2005.php - would be a file that has todays date - i use dates for filenames, as events happen on these days, and its easier to find them.

Files are currently automatically sorted after being created, into a folder, and subfolder, depending on what the filename date is, for example, 30-04-2005.php would go in the folder ./2005/04/ - whereas 05-06-2004.php would go in ./2004/06/.

The sorter I am looking for, will sort all the files that lie in the folder, into order, after they have been created, onto a list where each link goes to the particular file, preferably, with the name of the month at the top of the monthly list, the files that belong into the month, in date order (ie. 1st april, would be above 10th april) - and the list contains all the months for the year, in month order (ie. jan-dec), and the file with the list in, lies in the year folder, so it can be accessed easily.

One more small thing - for the current year, the files are all in reverse order, so that the latest file is at the top - but again, sorted into months, but going down from dec-jan

if no entry is made for a particular month, then that month shouldnt be on the list

if anyone could lend me a very big hand, or small chunks - then that would be great!

ironik

10:35 pm on May 1, 2005 (gmt 0)

10+ Year Member



You can't sort the files as they come out of the filesystem (as far as I am aware). What you will need to do is read the files into an array (lookup readdir()) and then use something like asort() or ksort() to sort your array into proper order before outputting to your page.