How do I access the checkbox field column value as a PHP array? I have a checkbox field for dining cuisine types and I see that the checked options are stored as a JSON-encoded array in the content table. If I have an element that uses this field, is there a way I can just get that JSON-encoded value as an array in PHP? Any time I try to get the value of the field, I'm getting the entire MultiOptionsFieldData object which isn't desired in this case. I just want that array of checked values that's stored in the corresponding content table column.



I don't want to write any loops. I just want access to that actual column value from my element in PHP.

I don't want to write any additional queries to get that column value either. Surely, there must be a way to get the actual field value for checkbox fields. Right?
MultiOptionsFieldData extends PHP's ArrayObject class.

You could get the values from it by casting it to an array like so:

$results = (array)$mofd;


That would give you an array of OptionData classes.  If you really didn't want to loop through them, you could do something like:

$func = static function($ofd) {
    return $ofd-&gt;value;
};

$results = array_map($func, (array)$mofd);