title: PHP - How can I Create Dynamic Bootstrap Rows & Columns in WordPress based on how many sub arrays an array has?
body: <p>I am using the <a href="https://www.advancedcustomfields.com/" rel="nofollow noreferrer">Advanced Custom Fields</a> plugin in WordPress to display rows of different employees. Basically, a User can input data in the Admin section, and it creates an array that can be used to display the data.</p>
  
  <p>Currently, The array is storing 5 values(subarrays):</p>
  
  <pre><code>array (
      0 =&gt; 
          array (
              'profile_pic' =&gt; 'http://ocdd.vztechsolutions.com/wp-content/uploads/2017/11/jaime.jpg',
              'profile_name' =&gt; 'Jaime Daignault',
              'profile_job' =&gt; 'Executive Director',
              'profile_email' =&gt; 'Jaimie.Daignault@ocdd.org',
          ),
      1 =&gt; 
          array (
              'profile_pic' =&gt; 'http://ocdd.vztechsolutions.com/wp-content/uploads/2017/11/beth.jpg',
              'profile_name' =&gt; 'Beth Kessler',
              'profile_job' =&gt; 'Family Engagement Coordinator',
              'profile_email' =&gt; 'Beth.Kessler@ocdd.org',
          ),
      2 =&gt; 
          array (
              'profile_pic' =&gt; 'http://ocdd.vztechsolutions.com/wp-content/uploads/2017/11/carrie.jpg',
              'profile_name' =&gt; 'Carrie Salehiamin',
              'profile_job' =&gt; 'Operations Manager',
              'profile_email' =&gt; 'CarrieS@ocdd.org',
          ),
      3 =&gt; 
          array (
              'profile_pic' =&gt; 'http://ocdd.vztechsolutions.com/wp-content/uploads/2017/11/leslie.jpg',
              'profile_name' =&gt; 'Leslie Sutton',
              'profile_job' =&gt; 'Policy Director',
              'profile_email' =&gt; 'Leslie.Sutton@ocdd.org',
          ),
      4 =&gt; 
          array (
              'profile_pic' =&gt; 'http://ocdd.vztechsolutions.com/wp-content/uploads/2017/11/ryley.jpg',
              'profile_name' =&gt; 'Ryley Newport',
              'profile_job' =&gt; 'Communications Director',
              'profile_email' =&gt; 'Ryley.newport@ocdd.org',
          ),
  )
  </code></pre>
  
  <p>I want to be able to create one Bootstrap row with 3 columns, if it has 3 subarrays. Otherwise, I want to create 2 rows, with 3 columns each, if there is more than 3 subarrays. So far this is what I created:</p>
  
  <pre><code>// Store Name of custom field(array) from Admin Section
  &lt;?php $repeater = get_field('staff'); ?&gt;
  
  &lt;?php if(count($repeater) &lt;= 3): ?&gt;
      &lt;?php while(have_rows('staff')) : the_row(); ?&gt;
          &lt;div class="row"&gt;
              &lt;div class="col-md-4 col-sm-6 col-xs-12 staffBlock"&gt;
                  &lt;img src="&lt;?php the_sub_field('profile_pic'); ?&gt;" alt="Profile Pic"&gt;
                  &lt;h4 class="staffTitle"&gt;&lt;?php the_sub_field('profile_name'); ?&gt;&lt;/h4&gt;
                  &lt;p class="staffSubTitle"&gt;&lt;?php the_sub_field('profile_job'); ?&gt;&lt;/p&gt;
                  &lt;a class="staffEmail" href="mailto:&lt;?php the_sub_field('profile_email'); ?&gt;"&gt;&lt;?php the_sub_field('profile_email'); ?&gt;&lt;/a&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;?php endwhile; ?&gt;
  
  &lt;?php elseif(count($repeater) &gt; 3 &amp;&amp; count(repeater) &lt;= 6): ?&gt;
      &lt;?php while(have_rows('staff')) : the_row(); ?&gt;
          // Display first row and 3 columns
          // Display second row and remaining columns
      &lt;?php endwhile; ?&gt;
  &lt;?php endif; ?&gt;
  </code></pre>
  
  <p>It works great if the Array has 3 subarrays, but I can't seem to wrap my head around how to create two different rows if it has more subarrays.</p>