I am using a foreach loop to run through an array. With it I have $q which iterates with a value of 1 on every loop run. And when the value reaches 1/3 of the total, it is to echo out new div, in order to make several columns. But I cant seem to find the error.
$i = 0;
$count = count($segments->getItems());
$countdiv = $count / 3;
$countdiv = number_format((float)$countdiv,0,',','');
$q = 0;
foreach($segments->getItems() as $segment)
{
$q++;
$allusers = 0;
if($segment->getName() === 'All Users') {
$allusers = "checked";
}
?>
<label class="custom-control custom-checkbox">
<input type="checkbox" name="<?php echo $segment->getName();?>" value="segments[]" class="custom-control-input" <?php echo $allusers?>>
<span class="custom-control-indicator"></span>
<span class="custom-control-description"><?php echo $segment->getName();?></span>
</label>
<?php
if($q === $countdiv)
{
?>
</div>
</div>
<div class="col-md-6">
<div class="custom-controls-stacked">
<?php
}
}
Aucun commentaire:
Enregistrer un commentaire