title: How do you generate a tile map with imagecreate from a php upload?
body: <p>I have an upload form which accepts multiple file uploads. Each file is 32px x 32px and I am trying to generate an image which contains each image in a grid. every row allows for 30 tiles and the column size is calculated based on the amount of tiles uploaded. For example if there's 120 images there would be 4 columns.</p>
  <p>The issue i'm facing is, I cannot seem to calculate the position of each tile in imagecopy. I'm getting the error: &quot;foreach() argument must be of type array|object, string given&quot; for the 2nd foreach loop.</p>
  <pre><code>&lt;?php
  $num_files = count($_FILES['myFiles']['tmp_name']);
  
  $image = imagecreate(960, ceil(round(30 / $num_files)));
  
  foreach($_FILES['myFiles']['tmp_name'] as $row =&gt; $columns) {
      foreach($columns as $col =&gt; $filename) {
          $tile = imagecreatefrompng($filename);
          imagecopy($image, $tile, $row * 32, $col * 32, 0, 0, 32, 32);
      }
  }
  
  header('Content-Type: image/png');
  imagepng($image);
  </code></pre>