title: Size of files of a scanned directory - PHP
body: <p>I want to read a directory and get the filesize of each file.
  I tried the following code:</p>
  
  <pre><code>$downloads = array_slice(scandir("downloads"),2);
  $size = array();
  foreach($downloads as $value) {
      $size = filesize("downloads/".$value);
      echo($size); //at this point the echo works correctly
  }
  echo($size); //shows the filesize of the first file
  echo($size[1]) //nothing happens
  foreach($size as $value) {
      echo($value); //nothing happens
      echo($size); //nothing happens
  }
  </code></pre>
  
  <p>That's why I'm quiet confused about the work with arrays and loops right now.
  It would also be nice to save the filenames and their corresponding filesizes in one array.</p>
  
  <p>Thanks for your suggestions.</p>