Change output last item in loop (ACF)

Viewed 3819

I'm still learning php, but can't get my head on this one.

For a loop in Wordpress I want to output a list with places, seperated with a comma and ending with a point.

Here's my code:

<?php if ( have_rows('subplaats') ): ?>
    <section id="subplaats">
        <div class="subplaats-container">
            <h3 class="support">Wij bestrijden ook in...</h3>
            <p>
                <?php while( have_rows('subplaats') ): the_row(); ?>
                    <?php $plaats = get_sub_field('plaats'); ?>
                    <?php echo $plaats; ?>,
                <?php endwhile; ?>
            </p>
        </div>
    </section>
<?php endif; ?>

Could anyone tell me how to accomplish this? I'm using Advanced Custom Fields. Am I also doing right on hierarchical level?

1 Answers
Related