I need to check the checkbox when the in_array function is true. The looping going fine but it checks all checkboxes whether the bool is true or false.
$pixArr
Array(
[12] => Array
(
[imgFile] => IMG_7516.JPG
[imgTime] => 11:39
)
[13] => Array
(
[imgFile] => IMG_7515.JPG
[imgTime] => 11:39
)
)
$dTime
Array(
[0] => 11-26-50
[1] => 11-26-50
[2] => 11-39-43
[3] => 11-39-43
[4] => 14-35-38
)
$fTime=11-26-50
foreach($pixArr as $key=>$val){
if(in_array($fTime,$dTime)){
echo "<input type=\"checkbox\" name=\"file[]\" value=\"$val[imgFile]\" checked/> Select</label>";
}else{
echo "<input type=\"checkbox\" name=\"file[]\" value=\"$val[imgFile]\"/> Select</label>";
}
}
I expect the input which time 11-26-50 is checked. Because is turns out the in_array true. But it checks every input in the loop. I don't understand why.