Reputation: 1952
I searched google for such solution but I couldn't find, I want to generate number beside each matched item, for example in emmet: If I wrote the following in my IDE that supports emmet:
ul>li.item$*5
It will generate:
<ul>
<li class="item1"></li>
<li class="item2"></li>
<li class="item3"></li>
<li class="item4"></li>
<li class="item5"></li>
</ul>
Is there a way to accomplish the same in Regex?
Thanx for your advice,
Upvotes: 0
Views: 60
Reputation: 14564
To generate a list with PHP you can use a simple loop, you don't need regex.
<ul>
<?php for ($i = 0; $i < 5; $i++) : ?>
<li class="item<?= $i; ?>"></li>
<?php endfor; ?>
</ul>
Upvotes: 4