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 ] . ') – ' . $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?
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.