Good day. Tell me, I need to output one array in the form of a checkbox, marking the checkboxes whose values are in the second array.
There are arrays
$prop = Array ( [values] => Array ( [0] => Пластиковые окна [1] => Натяжные потолки [2] => Установка дверей [3] => Укладка ламината [4] => Оклейка обоев ) ) $option_key = Array ( [0] => Натяжные потолки [1] => Оклейка обоев [2] => Пластиковые окна ); It is necessary to display $ prop array in the form of flags, but at the same time, those values that are in the $ option_key array should be noted.
I tried this way, he notes everything to me:
foreach ($prop as $k => $v) { foreach ($v as $values) { print "<label><input"; if (isset($prop[$k])) { print " checked "; } print "type='checkbox' name='$k'> $values</label>"; } }