title: PHP Recursively File Folder Scan Sorted by Modification Date
body: <p>I'm using this script to see all subfolders and files of subfolders</p>
  
  <pre><code>   function readfolder($dir)
      {
          global $tfile,$tdir;$i=0;$j=0;$myfiles;
          $myfiles[][] = array();
          if (is_dir($dir)) {
              if ($dh = opendir($dir)) {
                  while (($file=readdir($dh)) !== false) {
                      if (!is_dir($dir."\\".$file))
                      {
                          $tfile[$i]=$file;
                          $i++;
                          echo $dir."\\".$file." &lt;b&gt;File&lt;/b&gt;&lt;br&gt;";
                      }
                      else {
                          if (($file != ".") &amp;&amp; ($file != "..")) {
                          $tdir[$j]=$file;
                          echo $dir."\\".$file." &lt;b&gt;Directory&lt;/b&gt;&lt;br&gt;";
                          readfolder($dir."\\".$file);
                          $j++;
                          }
                      }
                  }
                  closedir($dh);
              }
          }
      }
  
      readfolder(".");
  </code></pre>
  
  <p>Can someone tell me how can I use filemtime function (or whatever) so that I can sort subflders and files by modification date?</p>