I display files and their date of addition on a page. I would like to add a sort by date but I don't know how to do it. Here is a piece of code:
$dir_a2    = 'serv_fic2/Anglais';
$files_a2  = scandir($dir_a2, 1);
$res = '<div class="container">
          <div class="row title">
            <div class="col-md-12">
              <h1>Gestion Documents Formateurs</h1>
            </div>
          </div>
          <div class="row title">';
$res .= '<div class="col-md-6">
            <b>Anglais</b>';
foreach ($files_a as $key => $value) {
  if(!in_array($value,array(".",".."))){
      $res .=   '<br>'.$value.
                '<i> | mis le : '.date ("d.m.y",filemtime('serv_fic/Anglais/'.$value)).'</i>'.
                '<a href="download.php?path=Anglais&file='.$value.'&down=form">
                  <input type="button" value="Telecharger">
                </a>
                <a href="delete_file.php?path=Anglais&file='.$value.'&u_id=Admin&type=Admin&delete=form">
                  <input type="button" value="Supprimer">
                </a>';
  }
}
 
     
    
https://stackoverflow.com/questions/6401714/php-order-array-by-date – Witzig Adrien Mar 22 '20 at 15:50