title: Generate multiple images with PHP
body: <p><strong>Code</strong></p>
  
  <pre><code>$files = scandir("images");
  $exclude = array(".", "..");
  
  $images = array_diff($files, $exclude);
  
  foreach($images as $image) {
  
      $original_image  = imagecreatefromjpeg("images/{$image}");
      $original_width  = imagesx($original_image);
      $original_height = imagesy($original_image);
  
      $new_width  = 180;
      $new_height = floor($original_height * ($new_width/$original_width));
      $new_image  = imagecreatetruecolor($new_width, $new_height);
  
      imagecopyresampled($new_image, $original_image, 0, 0, 0, 0, $new_width, $new_height, $original_width, $original_height);
  
      header("Content-Type: image/jpeg");
  
      imagejpeg($new_image);
  }
  </code></pre>
  
  <p><strong>Problem</strong></p>
  
  <p>The resizing part of the code works just fine, but it only outputs the first resized image. How can I make it so that it dumps all of the resized images?</p>