title: PHP unlink (delele ) multiple files on server
body: <p>Sometimes, I have to delete multiple files in different folders on the server. It's a tedious job to to this one by one via FTP. I wrote a little script that does the job. I can import the list of files in Excel and copy and paste them in the script. However, my approach is not elegant:</p>
  
  <pre><code>$file1 = "some-file.php";
  $file12 = "some-file2.php";
  
  ...
  
  if (!empty($file1)) {
  if ( @unlink ( $_SERVER[DOCUMENT_ROOT]."/".$file1 ) )
  {
    echo 'The file &lt;strong&gt;&lt;span style="color:green;"&gt;' . $file1 . '&lt;/span&gt;&lt;/strong&gt; was deleted!&lt;br /&gt;';
  }
  else
  {
    echo 'Couldn't delete the file &lt;strong&gt;&lt;span style="color:red;"&gt;' . $file1 . '&lt;/span&gt;&lt;/strong&gt;!&lt;br /&gt;';
  }}
  if (!empty($file2)) { ...
  </code></pre>
  
  <p>I would rather like to do this with a foreach and an array, but don't know how. Any help would be appreciated!</p>