Home › Forums › General Issues › Get one of each select value if it's used › Reply To: Get one of each select value if it's used
I would loop over the repeater once, gather all of the values into an array and then use the array.
A simple example:
$values = array();
while (have_rows($repeater) }
the_row();
$value = get_field('sub_field');
if (!in_array($value, $values) {
$values[] = $value;
}
}
// loop over the array and do something with each value.
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.