Create x amount of li according to variable $ pages in php

0

I have a variable $ pages that brings the amount of pages.

Then I need to create a li for each page, eg:

$paginas = 3;
sairia o resultado:
<li>1</li>
<li>2</li>
<li>3</li>
    
asked by anonymous 24.04.2018 / 19:45

1 answer

3

You can create a repeat loop for , while the counter is less than the number of pages one, li is printed with the value, I started the counter at 1 for the start list also start at number 1.

$paginas = 3;

for($i = 1; $i <= $paginas; $i++){
    echo "<li>$i</li>";
}
    
24.04.2018 / 19:52