title: How to wrap multiples of images in divs?
body: <p>I am trying to wrap some divs round images using PHP to show a max of 8 images per div.
  I am using custom fields WordPress plugin to pull out the images of the team but the need to wrap them in divs. I have it part working but it doesn't show a div for the remainder. I'm not sure if this is the best way but this is my code below.</p>
  
  <pre><code>function team($i,$t){                       
  
      $values = get_field('team_member'.$i);
  
  
  
  if($values["url"]){
  
  $answer = $i / 8;
  
      if(is_int($answer)){
  
          echo '&lt;div class="team'.$i / 8.'"&gt;'. "\r\n";
          echo $t;
          $t  =   '';
          echo '&lt;/div&gt;'. "\r\n";
  
      }                           
  
      $t .='&lt;a href="'.$values["url"].'" alt="'.$values["alt"].' Thumbnail" &gt;'. "\r\n";
      $t .='&lt;img src="'.$values["sizes"]["thumbnail"].'" alt="'.$values["alt"].'" /&gt;'. "\r\n";
      $t .='&lt;/a&gt;'. "\r\n";                                
      $i = $i+1;
  
      team($i,$t);
      }
  
  }
  
  team(1,'');
  </code></pre>
  
  <p>I am trying to get a result like below.</p>
  
  <pre><code>&lt;div id="team"&gt;
      &lt;div id="team1"&gt;
      &lt;img 1&gt;
      &lt;img 2&gt;
      ..
      &lt;img 7&gt;
      &lt;img 8&gt;
      &lt;/div&gt;
  
      &lt;div id="team2"&gt;
      &lt;img 1&gt;
      &lt;img 2&gt;
      ..
      &lt;img 7&gt;
      &lt;img 8&gt;
      &lt;/div&gt;
  
      &lt;div id="team3"&gt;
      &lt;img 1&gt;
      &lt;img 2&gt;
      ..
      &lt;img 7&gt;
      &lt;img 8&gt;
      &lt;/div&gt;
  
      &lt;div id="team4"&gt;
      &lt;img 1&gt;
      &lt;img 2&gt;
      &lt;img 3&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>