(or add comma to all items but the last one...)
Most of the information I have found relates to using a counter within a foreach loop. In this particular situation I am using Advanced Custom Fields and I am within a standard loop, not a foreach loop.
I need to add a comma to the end of each item except the last.
<?php while( has_sub_field('images') ): ?>
<?php $image = wp_get_attachment_image_src(get_sub_field('image'), 'wsn_canvas'); ?>
<?php echo $image[0]; ?>
//echo comma here
<?php endwhile; ?>
$output = $image[0] .','; endwhile; $output = substr_replace($output ,"",-1); echo $output;?? you can also get rid of all yourphptags .. you have noHTMLin there.