ACF gallery & bootstrap colls and rows [closed]

The easiest option would be to simply check if you are on every fourth iteration. Please see the following for an illustration, I haven’t tested this but see the basic idea.

<?php 

$images = get_field('portfolio');

if( $images ): ?>

        <?php foreach( $images as $key => $image ):

          if (($key + 1) % 4 == 0) { ?>
             <div class="row">
          <?php } ?>

             <div class="col-lg-3">    

                <a href="https://wordpress.stackexchange.com/questions/258982/<?php echo $image["url']; ?>">
                   <img src="https://wordpress.stackexchange.com/questions/258982/<?php echo $image["sizes']['thumb_front']; ?>" alt="https://wordpress.stackexchange.com/questions/258982/<?php echo $image["alt']; ?>" class="img-responsive"/>
                </a>
                <p><?php echo $image['caption']; ?></p>

             </div>

          <?php
          if (($key + 1) % 4 == 0) { ?>
            </div>      
          <?php }
          endforeach; ?>
    </div>