V
V
Vladislav2019-02-11 17:06:24
PHP
Vladislav, 2019-02-11 17:06:24

Advertising in a product category?

Good afternoon, please tell me how they put ads in the list of goods that most likely goes through foreach?5c61815c3672a960866242.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lander, 2019-02-11
@Vladyslawx

foreach ($goods as $index => $good) {
    if ($index % 3 == 0) {
        print_ad();
    }
    print_cart($good);
}

P
Pavel, 2019-02-11
@PavelMonro

There is a counter in the loop, and the condition after such a number to show ads, nothing complicated
. How to make a counter in foreach?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question