Support

Account

Home Forums Front-end Issues Chechbox not working in foreach Reply To: Chechbox not working in foreach

  • Hi @unmatched

    It’s possible that the “type” field doesn’t have value, so get_field() will returns an empty string while in_array() needs an array for the second parameter, not an empty string.

    I think you can check if it has a value or not first like this:

    $selected = get_field('type');
    if($selected){
        if( in_array('web', $selected) ) {
            echo 'web';
        }
    }

    I hope this helps.