The Most Active and Friendliest
Affiliate Marketing Community Online!

“AdsEmpire”/  Direct Affiliate

php sort using associative array

gilbertsavier

New Member
affiliate
Hi,
I'm using krsort, ksort, arsort and asort in a script. Fine all goes perfectly, except that the sort field is based on file names from the directory contents, and they are (historically) ugly, as in MMDDYY, not YYYYMMDD, causing the different years to be interspersed together.
if($_GET['sort'] == 'alpha'){
if($_GET['mode'] == 'desc'){
krsort($files);
$highlight = 'alpha_desc';
} else {
ksort($files);
$highlight = 'alpha_asc';
}
} else {
if($_GET['mode'] == 'asc'){
asort($files, SORT_NUMERIC);
$highlight = 'date_asc';
} else {
arsort($files, SORT_NUMERIC);
$highlight = 'date_desc';
}
}

----------
Thanks & regards,
Lokananth
 
MI
Back