Hi!
I use this code with my checkbox, but would like to remove the commas.
`
<p class=”shop-link”><?php the_field(‘shop’); ?></p>
`
I’ve searched the forum and tried different codes without any luck.
For example, this didn’t work so I appreciate all help!
`
<p class=”shop-link”><?php $values = get_field(‘checkbox’);
if ($values) {
foreach ($values as $value) {
echo str_replace(‘, ‘, ‘<br />’, $value);
}
} the_field(‘shop’); ?></p>
`
Thank you,
Caroline
get_field() will return an array of values
echo implode('<br />', $values);
Thank you @hube2
I managed to remove the commas, but now it returns the values x 5…
This is the code:
`<p class=”shop-link”>
<?php $values = get_field(‘shop’);
if ($values) {
foreach ($values as $value) {
echo implode(‘<br />’, $values);
}
} ?></p>
`
you need to either echo each value in the loop or implode and echo only once.
$values = get_field(‘shop’);
echo implode('<br />', $values);
OR
if ($values) {
foreach ($values as $value) {
echo $value,'<br />';
}
}
The benefit of using implode is that it eliminates the ‘<br />` after the final value.
Perfect @hube2 it works great now! Thank you so much!
How to remove commas on elementor?
Thanks