Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You'll have to :</p> <ul> <li>first, get a list of files, with, for each file, its last modification date (this can be fetched using <a href="http://www.php.net/filemtime" rel="nofollow noreferrer"><code>filemtime</code></a>)</li> <li>then, sort that list, with a user function that sorts depending on the "date" field you've got in you array (to sort using a user-defined function, see <a href="http://www.php.net/manual/en/function.usort.php" rel="nofollow noreferrer"><code>usort</code></a>)</li> <li>and, finally, display the list</li> </ul> <p>For instance, to first get the list of files :</p> <pre><code>$files = array(); $dir = dirname(__FILE__); $Dirdownloads=opendir($dir); while (false !== ($file = readdir($Dirdownloads))) { if($file != "." &amp;&amp; $file != ".."){ $files[] = array( 'name' =&gt; $file, 'date' =&gt; filemtime($dir . '/' . $file), ); } } closedir($Dirdownloads); </code></pre> <p>Note that, for each file, I have an array containing "<code>name</code>" and "<code>date</code>".</p> <p>And, then, to sort them :</p> <pre><code>usort($files, 'my_sort_function'); </code></pre> <p>And, the sort function that compares files based on the '<code>date</code>' field :</p> <pre><code>function my_sort_function($a, $b) { if ($a['date'] == $b['date']) { return 0; } return ($a['date'] &gt; $b['date']) ? -1 : 1; } </code></pre> <p>With this, the <code>$file</code> array should contain what you want :-) <br>Depending on the order you want, you'll use either <code>&gt;</code> or <code>&lt;</code> in the sorting function.</p> <p>Up to you to iterate over that list, to display the links !</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload