Fair warning, I'm a PHP noob. First post too :)
At the moment I have a ACF group with 3 subfields. I want to loop through these subfields and echo their 'label' and 'value'. If the subfield is empty, then I'd like the loop to skip/not echo the value. I can mimic the out with the the follow:
<?php
$objective_desc = "objective_desc";
$objective = get_field_object($objective_desc);
?>
<div class="item">
<?php if ( $objective_desc ): ?>
<h2 class="sub-sample-title"><?php echo $objective['label']; ?></h2>
<?php endif; ?>
<?php if ( $objective_desc ): ?>
<p class="sub-description"><?php echo $objective['value']; ?></p>
<?php endif; ?>
</div>
The problem is that I'd have to copy and past for every subfield in the group. Im sure there's a more elegant way of doing it.