Create x quantity of <li> according to variable $pages in php

Asked

Viewed 78 times

0

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

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

$paginas = 3;
sairia o resultado:
<li>1</li>
<li>2</li>
<li>3</li>

1 answer

3


You can create a repeat loop for, while the counter is less than the number of pages a, 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>";
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.