Hi ACF Community,
I have a small problem. I have a checkbox field with the numbers from 1 – 60. You can select 60 fields.
Usually you output the fields in a foreach loop, unfortunately I need the selected fields in an array ().
In the end it should look like this:
$seconds = array ("1" => 0, "2" => 0, "3" => 0, "4" => 0, "5" => 0, "20" => 0, "21" => 0, "22" => 0, "23" => 0, "24" => 0, "25" => 0, "26" => 0, "27" => 0, "28" = > 0, "29" => 0, "30" => 0, "60" => 0,);
That does not work:
$seconds = array (get_field_objects('second-field'));
That doesn’t work either
$values = array();
$time = get_field('second-field');
foreach ($time as $second) {
$values[] = '"'.$second.'" => 0, ';
}
$totalvalue = implode("\n", $values);
$seconds = array ($totalvalue)
Does anyone know how I can get the checkbox fields into the array?
Many thanks and best regards Christoph