I have this string:
$hours = '7, 8, 12';
$hourData = explode(', ', $hours);
if I var_dump($hourData), it returns:
array(3) {
[0]=>
string(1) "7"
[1]=>
string(2) "8"
[2]=>
string(2) "12"
}
and I have this code:
<?php for ($i=0; $i <= 23 ; $i++) { ?>
<div class="fl">
<input type="checkbox" name="limit_hour[]" value="<?php echo $i ?>" class="fl limit_hour"
<!-- ======================================================================== -->
<?php echo (isset($hourData[$i]) && $i == $hourData[$i] ? 'checked' : '') ?>>
<!-- ======================================================================== -->
<span class="fl lmBox"><?php echo $i ?>:00 - <?php echo $i ?>:59</span>
</div>
<?php } ?>
this code:
<?php echo (isset($hourData[$i]) && $i == $hourData[$i] ? 'checked' : '') ?>
I want to echo 'checked' for the checkbox who got the same value as my $hourData array value.
What should I do?