Answer the question
In order to leave comments, you need to log in
How to split foreach output into html blocks?
I display content in the site template in the amount of 10 news. In the template, the content is divided into blocks, the code is:
<div class="col-md-4">
<article class="card mb-4">
<header class="card-header">
<div class="card-meta">
<a href="#"><time class="timeago" datetime="2019-07-16 20:00">16 july 2019</time></a> in <a href="page-category.html">Work</a>
</div>
<a href="post-image.html">
<h4 class="card-title">How can we, how can we sing about ourselves?</h4>
</a>
</header>
<a href="post-image.html">
<img class="card-img" src="img/articles/3.jpg" alt="" />
</a>
<div class="card-body">
<p class="card-text">Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. </p>
</div>
</article><!-- /.card -->
<article class="card mb-4">
<header class="card-header">
<div class="card-meta">
<a href="#"><time class="timeago" datetime="2019-10-15 20:00">15 october 2019</time></a> in <a href="page-category.html">Lifestyle</a>
</div>
<a href="post-image.html">
<h4 class="card-title">The king is made of paper</h4>
</a>
</header>
<a href="post-image.html">
<img class="card-img" src="img/articles/20.jpg" alt="" />
</a>
<div class="card-body">
<p class="card-text">Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. </p>
</div>
</article><!-- /.card -->
</div>
<div class="col-md-4">
output two by two <article class="card mb-4">
$c = 1;
foreach($obj['itemListData'] as $key=>$val){
$id = $val['itemInfos']['id'];
$text = $val['itemInfos']['text'];
.. . шаблон ...
if ($c == 10) break;
$c++;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question