How to mark common elements as checked in checkbox php array -
i have 2 arrays.
elements of second array $array2
displayed through check boxes.
want common elements of both lists marked checked , rest left unchecked.
$array1 = array("a", "b"); $array2 = array("a", "b", "c", "d");
$common = array_intersect($array1, $array2); printf('<input type="checkbox" %s ...>', in_array('a', $common) ? 'checked' : null);
Comments
Post a Comment