Support

Account

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;