Loops and Breaking PHP Code
Let's form several paragraphs in a loop:
<?php
for ($i = 1; $i <= 9; $i++) {
echo '<p>' . $i . '</p>';
}
?>
The code can be rewritten with a PHP break:
<?php for ($i = 1; $i <= 9; $i++) { ?>
<p><?= $i ?></p>
<?php } ?>
For simplicity, you can use the alternative syntax:
<?php for ($i = 1; $i <= 9; $i++): ?>
<p><?= $i ?></p>
<?php endfor; ?>
Use a loop to form the following HTML code:
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>