Esempio di come lo farei io (se ho capito bene il problema):
Codice PHP:
$base_dir = '../news/archivio_news/';
$dh = opendir($base_dir);
$output = array();
while ( $file = readdir($dh) ) {
if ( $file == '.' || $file == '..' || $file == '.DS_Store' ) {
continue;
}
$timestamp = filemtime($base_dir . $file);
$output[] = array(
'timestamp' => $timestamp,
'data' => date('d/m/Y', $timestamp),
'titolo' => str_replace('.php', '', $file),
);
}
usort($output, 'custom_date_sort');
print_r($output);
function custom_date_sort($a, $b) {
$time_a = $a['timestamp'];
$time_b = $b['timestamp'];
if ( $time_a == $time_b )
return 0;
return $time_a < $time_b ? -1 : 1;
}