Hi,
I've got this script that scans a directory for folders that are exactly 6 characters, where the first two digits are the month, second two digits are the day, and the last two digits are the year.
This script is supposed to sort (descending) the listing by date and return a string, such as "122701" representing the newest dated directory (each date is a publication for our online newspaper).
==========File Structure==========
- archive
- 112701
- HTML Files
- 122001
- HTML Files
- 122501
- HTML Files
- 122701
- HTML Files
- 010102
- HTML Files
The script worked okay, until the "010102" directory was introduced. I was using an 'rsort' function to sort a simple array of directory entries. Now the new directory, "010102" is listed at the bottom instead of the top.
I thought about parsing each entry and creating a multidimensional associative array, where the array is divided by year, month and date (the "01" key would contain an associative array with 2001 entries) like the following:
01 (Year 2001)
-11 (Month of November)
("27")
-12 (Month of December)
("20, 25, 27" )
02 (Year 2002)
-01 (Month of January)
("01, "03")
or in other words, like this:
$listing = array("01" => array ("12" => array ("25", "27"), "11" => array("27")), "02" => array ("01" => array ("01"));
I don't know how to reference assoc. arrays very well or how to sort them.
I'm at my wit's end here. I am by no means a php expert, and still learning the language. Any help would be greatly appreciated.
Thanks,
Jason