I am using a while loop that is as follows:
<?php while(has_sub_field('available_locations')): ?>
<a href="<?php the_sub_field('location_url'); ?>"><?php the_sub_field('locations'); ?></a>,
<?php endwhile; ?>
The problem is that Last Location has also comma with it. For example:
California, Texas,
But I would like to look it like this:
California, Texas
Since this is containing both HTML and PHP codes, should I store in a variable and use rtrim to cut the last comma, or there is something better solution for it. If I put this in variable, personally I think this is not good solution. Please do respond.
Update: The question is not about only removing last character rather it contains an anchor tag which if I store in a variable, then it is not creating hypertext.Like
But after storing it in variable, the result is like this:
https://www.google.co.in Google