aussi j'attends de votre part une efficacité
J'ai mis en place un système de tri par ordre alphabétique, et j'aurais besoin de faire de même en ce qui concerne la date de modification. Et malheureusement, ça coince.
Relis donc ... c'est fait ? Tu as enfin compris que je n'arrivais pas à mettre en place un système de tri par date dans la liste générée ?
Un code, quel code, vu que je n'arrive pas à le faire.
Je souhaite simplement que l'on m'éclaire
<?php function cmp_name($a,$b) { global $asc; if ($a['name'] == $b['name']) return 0; if($asc == 'a') { return ($a['name'] < $b['name']) ? -1 : 1; } else { return ($a['name'] > $b['name']) ? -1 : 1; } } function ScanDossier($Directory) { $Doss = '/Philo'; //Attention a bien laisser un '/' devant le chemin d'acces des images, si celles ci ne sont pas à la racine du site $url = 'http://'.$_SERVER["SERVER_NAME"].''.$_SERVER["REQUEST_URI"]; $Fichiers = array(); $Dossiers = array(); $DateFichiers = array(); $i = 0; $j = 0; $MyDirectory = opendir($Directory) or die('Erreur'); while($Entry = @readdir($MyDirectory)) { if(is_dir($Entry)){ if ($Entry == "..") { echo '<tr><th scope="col" style="text-align: left;">['.$Entry.' Dossier superieur]</th><th scope="col"> - </th><th scope="col"> - </th></tr>'; } elseif ($Entry == ".") { echo '<tr><th scope="col" style="text-align: left;">['.$Entry.' Dossier actuel]</th><th scope="col"> - </th><th scope="col"> - </th></tr>'; } else { $Dossiers[$j] = $Entry; $j = $j + 1; } } else { //$DateFichiers[] = ; $Fichiers[filemtime($Entry)] = $Entry; } } $DateFichiers = array_keys($Fichiers); $count = count($Fichiers); $count1 = count($Dossiers); if(!empty($_GET['tri'])){ $tri = $_GET['tri']; if($tri == "nomz"){ usort($Fichiers,"cmp_name"); usort($Dossiers,"cmp_name"); } else if ($tri == "noma") { sort($Fichiers); sort($Dossiers); } } else { sort($Fichiers); sort($Dossiers); } for ($j = 0; $j < $count1; $j++) { echo '<tr>'; echo '<th scope="col" style="text-align: left;">['.$Dossiers[$j].' '.$Dossiers[$j].']</th><th scope="col"> - </th><th scope="col"> - </th>'; echo '</tr>'; } for ($i = 0; $i < $count; $i++) { if($i&1) { echo '<tr>'; } else { echo '<tr style="background-color: #EEEEEE;">'; } echo '<th scope="col" style="text-align: left;">['.$Fichiers[$i].' '.$Fichiers[$i].']</th><th scope="col">'.dd($DateFichiers[$i]).'</th><th scope="col" style="text-align: Right;">'.taillefichiers(filesize($Fichiers[$i])).'</th>'; echo '</tr>'; } closedir($MyDirectory); echo '<tr><th>Il y a '.$j.' dossiers et '.$i.' fichiers.</th><th></th><th></th></tr>'; } ?>