I trying to compare 2 Arrays and then let the Checkbox to be checked if there are common values between them.
coding
$array_1[]="value1";
$array_1[]="value2";
$array_1[]="value3";
$array_1[]="value4";
$array_1[]="value5";
$array_1[]="value6";
$array_1[]="value7";
$array_1[]="value8";
$array_2[]="value1";
$array_2[]="value3";
$array_2[]="value4";
for($i=0;$i<count($array_1);$i++){
$checked = isset($array_2[$i])? 'checked' : '';
echo '<input type="checkbox" ' . $checked .' name="zzz[] "value="'.$array_1[$i].'"> '.$array_1[$i].'<br>';
}
as you can see from the screenshot, the correct result should be right side with value1, value3 and value4. However, my php output is leftside of the screenshot
Anyone knows what's wrong ?
