title: Get specific row in repeater with specific value
body: <p>I'm using an <a href="https://www.advancedcustomfields.com/resources/repeater/" rel="nofollow noreferrer">Advanced Custom Fields repeater field</a> that has two fields for each row - <code>image</code> and <code>main_image</code>.</p>
  
  <p>If <code>main_image</code> in a row has "Yes" selected then I want it to output the <code>image</code> from that row. If "Yes" isn't selected for any rows then I just want it to select the first <code>image</code>.</p>
  
  <p>Where am I going wrong?</p>
  
  <pre><code>&lt;?php if( have_rows( 'gallery' ) ): ?&gt;
    &lt;?php $rowcounter = 1;
    while( have_rows( 'gallery' ) ): the_row(); ?&gt;
      &lt;?php $image = get_sub_field( 'image' ); ?&gt;
  
      &lt;?php if(get_sub_field('main_image') == "Yes") { ?&gt;
  
        &lt;a href="#" class="slide"&gt;
          &lt;img src="&lt;?php echo $image[$rowcounter]['url']; ?&gt;" alt="&lt;?php echo $image[$rowcounter]['alt']; ?&gt;"&gt;
        &lt;/a&gt;
  
      &lt;?php } else { ?&gt;
  
        &lt;a href="#" class="slide"&gt;
          &lt;img src="&lt;?php echo $image[1]['url']; ?&gt;" alt="&lt;?php echo $image[1]['alt']; ?&gt;"&gt;
        &lt;/a&gt;  
  
      &lt;?php } ?&gt;  
  
  
    &lt;?php $rowcounter++;
    endwhile; ?&gt;
  &lt;?php endif; ?&gt;
  </code></pre>
  
  <p>I thought by doing this <code>&lt;?php echo $image[$rowcounter]['url']; ?&gt;</code> it would output the image from that row.</p>
  
  <p><a href="https://i.stack.imgur.com/hlkMK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hlkMK.png" alt="enter image description here"></a></p>