title: How do Display A Layout With a Variable Number of Items in an Array (PHP)
body: <p>If I give you an <code>array</code> of objects, lets assume there are x number of objects how would you do the following using a grid system (bootstrap, foundation ... doesn't matter):</p>
  
  <p>Loop Over the array and create something that replicates:</p>
  
  <p><a href="https://i.stack.imgur.com/cm33p.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cm33p.jpg" alt="enter image description here"></a></p>
  
  <p>No I have been able to create this by doing:</p>
  
  <pre><code>echo "&lt;div class='row'&gt;";
      for($i = 0; $i &lt; count($options['fields']); $i++) {
  
          // Increate the value of I and convert it from 1 to one.
          $numberToWord = new FreyaTheme\NumberToWord\Conversion();
          $wordRepersentation = $numberToWord-&gt;convert($i + 1);
  
          if (isset($options['fields']['logo_image_' . $wordRepersentation])) {
              if ($i &lt;= 2) {
                  echo '&lt;div class="medium-4 columns r3x1"&gt;';
                      echo '&lt;img src="'.$options['fields']['logo_image_' . $wordRepersentation].'" /&gt;';
                  echo '&lt;/div&gt;';
              } else if ($i &lt;= 6) {
                  echo '&lt;div class="medium-3 columns r4x1"&gt;';
                      echo '&lt;img src="'.$options['fields']['logo_image_' . $wordRepersentation].'" /&gt;';
                  echo '&lt;/div&gt;';
              } else if ($i &lt;= 9) {
                  echo '&lt;div class="medium-4 columns r3x1"&gt;';
                      echo '&lt;img src="'.$options['fields']['logo_image_' . $wordRepersentation].'" /&gt;';
                  echo '&lt;/div&gt;';
              }
          }
      }
  echo "&lt;/div&gt;";
  </code></pre>
  
  <p>Now this, while a bit messy with the logic here - works for 10 items. Now imagine I give you 800. or 8 or 2 or 1 or ... you get the idea. Regardless of how many items I give you, this pattern, this box layout needs to repeat. I don't care if you give me 6 or 6000 objects.</p>
  
  <p><strong>I can do this with 10, but I don't know how to scale it. Ideas?</strong></p>