Home › Forums › Add-ons › Repeater Field › Repeater sub field display by group based on value › Reply To: Repeater sub field display by group based on value
If the array is sorted in the right order something like this will show them… I’m guessing at a bit of this because you didn’t actually give the field names and you’ll need to adjust the loop to output what you want. This is just an example of how to loop through an array that has been grouped together by one of it’s elements.
$last_group = ''; // initialize the group name
foreach ($personArray as $person) {
$this_group = $person['group_name'];
if ($this_group != $last_group) {
echo '<h2>',$person['group_name'],'</h2>';
}
$last_group = $this_group;
echo '<p>'.$person['person_name'].'</p>';
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.