Ciao,
ho questo codice che con il ciclo mi visualizza i documenti presenti in una cartella e con la funzione natsort da un ordinamento naturale
<?
echo "<TABLE BORDER=\"0\" WIDTH=\"90%\" CELLPADDING=\"5\" CELLSPACING=\"5\">";
error_reporting (0);
$SortArray = array();
if ($handle = opendir('../blog')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != "ricerca.php" && $file != "counter") {
$SortArray[] = $file;
}
}
closedir($handle);
}
natsort($SortArray);
foreach($SortArray as $file) {
echo "<TR><TD CLASS=\"download_a\">";
$scatti ="$file/contatore.txt";
echo "<A HREF=\"../blog/$file\">$file</A>";
$filename = "../blog/$file";
if (file_exists($filename)) {
echo "ultimo aggiornamento: " . date("d.m.Y", filectime($filename));
echo "";
}
echo "<H6></H6>";
include "../blog/counter/".substr("$file",0,-4).".php.desc";
echo "</TD><TD CLASS=\"download_b\">";
include "../blog/counter/".substr("$file",0,-4).".php.txt";
echo "</TD></TR>";
}
echo "</TABLE>";
?>
però non elenca correttamente i documenti con il nome come una data tipo 01.02.2008.php 12.04.2008.php ecc . . . non leggendo il numero che segue dopo il punto e non li ordina correttamente - vedi esempio
http://www.semafolle.it/page/blog.php
ho provato anche le funzioni - strnatcmp() e altre ma non corregge.
Potete darmi utili suggerimenti?