title: php script to delete files older than 24 hrs, deletes all files
body: <p>I wrote this php script to delete old files older than 24 hrs,
  but it deleted all the files including newer ones:</p>
  
  <pre><code>&lt;?php
    $path = 'ftmp/';
    if ($handle = opendir($path)) {
       while (false !== ($file = readdir($handle))) {
          if ((time()-filectime($path.$file)) &lt; 86400) {  
             if (preg_match('/\.pdf$/i', $file)) {
                unlink($path.$file);
             }
          }
       }
     }
  ?&gt;
  </code></pre>