title: How to generate multiple xls files with a for loop using content-type
body: <p>Before an apology, it is my first question and little English. </p>
  
  <p>I need to generate multiple excel files with PHP, running a for loop. Each file must be renamed, the problem is that I only generate one in this case "ELEMENT THREE.xls". </p>
  
  <p>In my file I got three lines :</p>
  
  <pre><code>CONTENT FILE ELEMENT ONE.xls
  -------------------------------
  CONTENT FILE ELEMENT TWO.xls
  -------------------------------
  CONTENT FILE ELEMENT THREE.xls
  -------------------------------
  </code></pre>
  
  <p>This is my code :</p>
  
  <pre><code>$elements = array('ELEMENT ONE','ELEMENT TWO','ELEMENT THREE');
  
  foreach ($elements as $element) {
  
      $table = "&lt;table border='1'&gt;&lt;tr&gt;&lt;td&gt;CONTENT FILE $element.xls&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;";
  
      header("Content-Disposition: attachment; filename=$element.xls");
      header("Content-Type: application/vnd.ms-excel");
      header('Expires: 0');
      header('Pragma: no-cache');
  
      echo utf8_decode($table);
  }
  </code></pre>
  
  <p>Thanks in advance</p>