I have a grid that has three columns per row. I would like to add an advertisement
every row but randomly placed (could be placed on the first, second or third column)
. I have used this answer to create the grid Loop row in bootstrap every 3 columns but every time that I have tried ends up showing the advertisement
but jumps one of the giveaways.
$numOfCols = 3;
$rowCount = 0;
$bootstrapColWidth = 12 / $numOfCols;
<div class="row">
@foreach($giveaways as $key => $giveaway)
@if($key == 0 || $key == 3 || $key == 6)
ADS HERE
@else
<div class="col-sm-{{ $bootstrapColWidth }} text-center">
SHOW GIVEAWAY
</div>
@endif
<?php
$rowCount++;
if($rowCount % $numOfCols == 0){
echo '</div><div class="row" style="margin-top: 5px; margin-bottom: 5px;">';
}
?>
@endforeach
</div>
At the example above I have tried using the most right square to display the adversitesement
but I would like it to be a random column.