I have check box inside a foreach loop so that i want to checkbox checked.
<?php
$heads = TCG\Voyager\Models\Head::all();
$i=0;
foreach($heads as $heads){
$headvalues=explode(',',$test->reporting_head);
echo $headvalues[$i];
echo '<br>';
echo $heads->id;
?>
<input type="checkbox" name="check_list[]" value="{{$heads->id}}_{{$heads->email}}" <?php echo (($headvalues[$i]==$heads->id)? 'checked' : ''); ?>><label>{{$heads->headname}}</label>
<?php
$i++;
}
?>
Here echo $headvalues[$i] are 1, 2 ,3 and echo $heads->id are 1,3,2.so i want to checked all this check boxes but now only one check box is checked.i think my logic has issue.I tried the following
<?php echo (($headvalues[$i]==$heads->id)? 'checked' : ''); ?>
Please help me