Support

Account

Home Forums General Issues ACF Checkbox Field in array() Reply To: ACF Checkbox Field in array()

  • Hi @unbekannter

    The below will output the selected checkboxes into an array:

    
    $values = array();
    $time = get_field('second-field');
    foreach ($time as $second) {
        $values[] = '"'.$second.'" => 0'; 
    }
    
    echo implode(',', $values);
    

    Do you need it as an associative array? I’m trying to work out it out.
    You asked for checkboxes to be an array but the example you give of how it needs to be is more like an associative array (I believe but could be wrong!).