Hello jlhaslip ,
This same approach would work for months or days. Basically, the way the function works now this is what happens:
your string might look like this "wednesday_m234.jpg" but the sort function reads it like "3_m234.jpg".
While it doesn't output the 3 instead of the wednesday, it knows that they are the same.
As a result, wednesday_m250.jpg would be ordered after wednesday_m234.jpg becasue, the sort function will just look to the next character to determine if it is before or after the other string.
So, you could change the function to use month names instead of weekday names.
Like so:
$search_strings = array("Sunday","Sun","Su","Monday","Mon","Mo","Tuesday","Tues","Tue","Tu","Wednesday","Wed","We","Thursday","Thurs","Thur","Thu","Th","Friday","Fri","Fr","Saturday","Sat","Sa" );
$replace_string = array('0','0','0','1','1','1','2','2','2','2','3','3','3','4','4','4','4','4','5','5','5','6','6','6' );
to this:
$search_strings = array("January", "Jan", "February", "Feb", "March", "Mar", "April", "Apr", "May", "June", "Jun", "July", "Jul", "August", "Aug", "September", "Sept", "Sep", "October", "Oct", "November", "Nov", "December", "Dec" );
$replace_string = array('901','901','902','902','903','903','904','904','905','906','906','907','907','908','908','909','909','909','910','910','911','911','912','912' );
That would change the ArraySortByDay function to sort by Month names instead.
It is also possible to do both at the same time! Just combine the old and new arrays instead of replacing the old one.
There are limitations to such a method. For example in this is how this list would be sorted.
Monday_December_28_2008
Tuesday_March_28_2000
Tuesday_March_29_1901
Tuesday_July_09_2001
Thursday_January_01_1492
As you can see, the dates will not sort as you might wish because the function would see those dates like this:
1_912_28_2008
2_903_28_2000
2_903_29_1901
2_907_09_2001
4_901_01_1492
The function is rather dumb in it's technique.
Basically, if you wanted to sort by year, then by month name, and then by weekday name, then you would have to format your strings accordingly like so:
YYYY_month_day.ext
One last thought, the years would be oldest first instead of most recent first.
It could be possible to use some date methods to reformat your strings to a more uniform system. The Reformat Date function found here:
http://www.handyphp.com/index.php/PHP-Resources/Handy-PHP-Functions/reformat_date.html may help.
This function makes every attempt to read a date and convert it to the format you specify.
Hope this helps,
vujsa