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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -