ACF / PHP Repeater count
<p>I have a repeater using Advanced Custom fields, which when a count reaches a total (of 3) based on an iterative count, I would like to output a div, then reset the counter.</p>

<p>Here's the code, at the moment it's not outputting as it should and I don't know enough about math to get it to work.</p>

<p>Appreciate your assistance :-)</p>

<pre><code>      &lt;?php if(have_rows('flexible_row')) : ?&gt;
  &lt;div class="row"&gt;
    &lt;?php if(empty($count)){ $count=1;} while(have_rows('flexible_row')) : the_row(); ?&gt;
        &lt;?php if(get_sub_field('column_width') == "One column") { $count = $count+1; ?&gt;
          &lt;div class="col-sm-4"&gt;
            &lt;?php the_sub_field('title');?&gt;
            &lt;?php the_sub_field('content');?&gt;
            Count is &lt;?php echo $count; ?&gt;
            &lt;hr/&gt;
          &lt;/div&gt;
        &lt;?php } if(get_sub_field('column_width') == "Two columns") { $count = $count+2; ?&gt;
          &lt;div class="col-sm-8"&gt;
            &lt;?php the_sub_field('title');?&gt;
            &lt;?php the_sub_field('content');?&gt;
            Count is &lt;?php echo $counter; ?&gt;
            &lt;hr/&gt;
          &lt;/div&gt;
        &lt;?php } else { $count = $count+3; ?&gt;
          &lt;div class="col-sm-12"&gt;
            &lt;?php the_sub_field('title');?&gt;
            &lt;?php the_sub_field('content');?&gt;
            Count is &lt;?php echo $counter; ?&gt;
            &lt;hr/&gt;
          &lt;/div&gt;
      &lt;?php } if ($count == 3) {  ?&gt;&lt;/div&gt;&lt;div class="row"&gt;&lt;?php $count = 0; } ?&gt;
    &lt;?php endwhile; ?&gt;
  &lt;/div&gt;
&lt;?php endif; ?&gt;
</code></pre>