I have the following raw HTML code:
<section class="cols services-modern">
<div class="container">
<div class="row-fluid">
<div class="span4">
<i class="content"></i>
<h3>Title</h3>
<p>Blah.....</p>
</div>
<div class="span4">
<i class="content"></i>
<h3>Title</h3>
<p>Blah.....</p>
</div>
<div class="span4">
<i class="content"></i>
<h3>Title</h3>
<p>Blah.....</p>
</div>
</div>
</div>
</section>
Which i would like to loop after the div has been filled with 3 contents. So far i have done the following with no luck..
<?php for($i = 0; $i < sizeof($content); $i++) : ?>
<section class="cols services-modern">
<div class="container">
<div class="row-fluid">
<?php if($i % 3 == 0): ?>
<div class="span4">
<i class="content"></i>
<h3>Title</h3>
<?= htmlspecialchars_decode($blah); ?>
</div>
<?php else: ?>
<div class="span4">
<i class="content"></i>
<h3>Title</h3>
<?= htmlspecialchars_decode($blah); ?>
</div>
<?php endif; ?>
</div>
</div>
</section>
<?php endfor; ?>
Could anyone help me to spot my mistake, thanks.
This is what u expecting?
<section class="cols services-modern">
<div class="container">
<div class="row-fluid">
<?php for($i = 0; $i < sizeof($content); $i++) : if($i % 3 == 0): ?>
<div class="span4"> <i class="content"></i>
<h3>Title</h3>
<?= htmlspecialchars_decode($blah); ?>
</div>
<?php else: ?>
<div class="span4"> <i class="content"></i>
<h3>Title</h3>
<?= htmlspecialchars_decode($blah); ?>
</div>
<?php endif; endfor; ?>
</div>
</div>
</section>
try this one..
<?php for($i = 0; $i < sizeof($content); $i++) : if($i % 3 == 0): ?>
<section class="cols services-modern">
<div class="container">
<div class="row-fluid">
<div class="span4"> <i class="content"></i>
<h3>Title</h3>
<?= htmlspecialchars_decode($blah); ?>
</div>
<?php else: ?>
<div class="span4"> <i class="content"></i>
<h3>Title</h3>
<?= htmlspecialchars_decode($blah); ?>
</div>
</div>
</div>
</section>
<?php endif; endfor; ?>