title: $_FILES array and its silly structure
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5444827/how-do-you-loop-through-files-array">How do you loop through $_FILES array?</a>  </p>
  </blockquote>
  
  
  
  <p>For some reason arrays really get to me.  I can get there in the end, but this $_FILES array seems to be backwards to me.</p>
  
  <p>I want to be able to loop through $_FILES like so:</p>
  
  <pre><code>foreach($_FILES as $file)
  {
     echo $file['name'] . "&lt;br&gt;";
     echo $file['type'] . "&lt;br&gt;";
     echo $file['size'] . "&lt;br&gt;";
     echo $file['error'] . "&lt;br&gt;";
  }
  </code></pre>
  
  <p>But obviously with the way its structured you cannot do that.  So I have written the following:</p>
  
  <pre><code>echo "&lt;pre&gt;";
                  $x=0;
                  $file = array();
                  foreach($_FILES['attachment']['name'] as $data)
                  {   $file[$x]=array(); 
                      array_push($file[$x],$data); $x++;
                  }
                  $x=0;
                  foreach($_FILES['attachment']['type'] as $data)
                      {   array_push($file[$x],$data); $x++;}
  
                  $x=0;
                  foreach($_FILES['attachment']['tmp_name'] as $data)
                      {   array_push($file[$x],$data); $x++;}
                  $x=0;
                  foreach($_FILES['attachment']['error'] as $data)
                      {   array_push($file[$x],$data); $x++;}
                  $x=0;
                  foreach($_FILES['attachment']['size'] as $data)
                      {   array_push($file[$x],$data); $x++;}
                  var_dump($file);
                  echo "&lt;/pre&gt;";
  </code></pre>
  
  <p>Which seems very long winded and rediculous but my mind is stuck at the moment as to how to loop through properly the different parts of this array to get it work and loop the way I want it to.</p>
  
  <p>There must be a better way?</p>
  
  <p>Please help!</p>