Support

Account

Home Forums General Issues Using ACF With Associative Arrays Reply To: Using ACF With Associative Arrays

  • @elliot Simple is always better! Thanks once again, Elliot!

    I had to throw in a conditional argument, though, as the ‘max’ value isn’t always present.

    if( get_sub_field('to') == true ) {
    echo '<p>Min: ' . $min . 'mm (US' . $conversion[ $min ] . ') &ndash; ' . $max . 'mm (US' . $conversion[ $max ] . ')</p>'; }
    
    else {
    echo '<p>Min-Max: ' . $min . 'mm (US' . $conversion[ $min ] . ')</p>'; }
    

    One question I had is how are you pulling the $min variable in $conversion[ $min ]? Or is that simply just grabbing the value from my sub field, matching it in the array and pumping out its associated value?