Forum Moderators: coopster
$temp = $array;
$temp2 = array();
foreach($temp as $key => $i){
//set the key to the date modified with and incrementer
$modifyDate = floatval(date("YmdHis", (filemtime($i))));
//these ifs check to see how big the counter is to put in the appropriate amount of 0s
//eg. if the counter is less than 10 then we need 4 0s so the counter looks like 00002
//if it is less than 100 then we need 3 0s so the counter looks like 00055
if($key < 10){
$temp2[$i] = floatval($modifyDate."0000".$key);
}//if key < 10
elseif($key < 99){
$temp2[$i] = floatval($modifyDate."000".$key);
}//else if key < 99
elseif($key < 999){
$temp2[$i] = floatval($modifyDate."00".$key);
}//else if key < 999
elseif($key < 9999){
$temp2[$i] = floatval($modifyDate."0".$key);
}//else if key < 99
else{
$temp2[$i] = floatval($modifyDate.$key);
}//else
}//foreach
arsort($temp2);
$counter = 0;
//now we set the keys back to the values
foreach($temp2 as $key => $value){
$temp[$counter] = $key;
$counter++;
}//foreach
return $temp;
}// sortArrayByDate