E
E
Egor Ogurtsov2015-11-26 21:12:03
PHP
Egor Ogurtsov, 2015-11-26 21:12:03

How to insert an element after the X and Y element in a list?

There is a simple list

<?php foreach ($this->rows as $k=>$blah) : ?>

<div class="someclass">blah-blah</div>

<?php endforeach; ?>

How to insert something after every second element and after every fourth, so that the output is like this?
<div class="someclass">blah-blah</div>
<div class="someclass">blah-blah</div>
<div class="someclass">FOO</div>
<div class="someclass">blah-blah</div>
<div class="someclass">blah-blah</div>
<div class="someclass">BAR</div>
<div class="someclass">blah-blah</div>
<div class="someclass">blah-blah</div>
<div class="someclass">FOO</div>
<div class="someclass">blah-blah</div>
<div class="someclass">blah-blah</div>
<div class="someclass">BAR</div>

и так далее

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question