Home › Forums › General Issues › Get max value from two arrays inside two ACF nested repeaters › Reply To: Get max value from two arrays inside two ACF nested repeaters
I think one of your problems is that you are using strings (text fields) to store numbers, but I’m not sure because you didn’t display the code that is outputting the max value.
I would likely to something like this
$max = 0;
if (have_rows('sales') {
while (have_rows('sales')) {
the_row()
$value = intval(get_sub_field('all_regions_percentage_off'));
if ($value > $max) {
$max = $value;
}
if (have_rows('different_regions')) {
while (have_rows('different_regions')) {
the_row();
$value = intval(get_sub_field('percentage_off'));
if ($value > $max) {
$max = $value;
}
}
}
}
}
echo $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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.