When creating a number of check box fields…ACF creates a numerically indexed array with the field Labels/Values as the value to numbered indexes. Is there a way to have the label be the key and 1/0 be the value?
I have check boxes to select the color(s) of something…and it would be much easier to deal with the data if it was:
Yeah, I tried messing with that but it appears to be label:value not key:value. They key still remains numeric.
I’m trying to find similarities and differences between two arrays that are populated with ACF data. The issue becomes that the positions of values change between different arrays based on whether the values exist…so comparison becomes complicated. Not insurmountable…just more complicated.
It depends on the return value setting what you get back. get field will always be numeric keys. If you want both label and value or just the label there is a setting for that. If you need something more complicated then you need to get what’s available and create it yourself using PHP functions.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users