E
E
Eugene2018-02-21 08:53:03
PHP
Eugene, 2018-02-21 08:53:03

How to make a correct counter?

The question is really simple, but I tried something like 5 options and everything is not right.
In general, there is a widget

<div class="panel">
    <div class="panel-heading">
        <h4 class="panel-title">
            <a data-toggle="collapse" data-parent="#accordion-alt3" href="#collapse1-alt3">
                <i class="fa fa-angle-right"></i><?=$category['name']?>
            </a>
        </h4>
    </div>
    <?php if(!empty($category['doc'])):  ?>
    <div id="collapse1-alt3" class="panel-collapse collapse">
        <div class="panel-body">
            <?=$this->getMenuHtml($category['doc']); ?>
        </div>
    </div>
    <?php endif; ?>
</div>

And there in some places there is collapse1-alt3.
I need the number after collapse to increase by 1 each time the block is built.
collapse1-alt3
collapse2-alt3
collapse3-
alt3

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lander, 2018-02-21
@usdglander

$i = 1;
...
<div id="collapse<?=$i++?>-alt3" class="panel-collapse collapse">

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question