title: how delete All files except one in folder with php?
body: <p>i have this php code to delete all images file in folder, but i need to keep example.php file.</p>
  
  <p>how i can?</p>
  
  <pre><code>$dir = @opendir('../result_image/');
  while (false !== ($file = @readdir($dir)))
  {
      if ($file != '..' &amp;&amp; $file != '.')
      {
      $upload[] = $file;
      }
  }
  
  $time_sec=@time();
      for($i=0;$i&lt;count($upload);$i++)
      {
      $time_file=@filemtime('../result_image/'.$upload[$i]);
      $time=$time_sec-$time_file;
  if($time&gt;9000)
      {
          //if ($upload[] = "disk_save.php") continue;
          @unlink('../result_image/'.$upload[$i]);
        }
     }
  </code></pre>
  
  <p><strong>I have 3 answer for my questions and all of them can work.but witch of them is best ? this code execute every time users upload picture.</strong></p>