Advanced Custom Fields has tons of exciting and amazing options to make your website feature rich. Many of those fields can return values in arrays. here are the examples to print the array values.
Using forEach loop
$values = get_field('field_name');
if($values)
{
echo ' ';
foreach($values as $value)
{
echo '- ' . $value . '
';
}
echo '
';
}
Using for loop
$values = get_field('field_name');
if($values)
{
echo ' ';
for($i = 0; $i++; $i <= count($values))
{
echo '- ' . $value[$i] . '
';
}
echo '
';
}
Using while loop
$values = get_field('field_name');
if($values)
{
echo ' ';
$i = 0;
while($i <= count($values)) {
echo '- ' . $value[$i] . '
';
$i++;
}
echo '
';
}
ACF advanced array custom for loop forEach loop