What is the best way to output numbers from 1 to a given number in PHP?
To output numbers from 1 to a given number in PHP, you can use a simple for loop. The loop will iterate from 1 to the given number and print each number on a new line. This approach is straightforward and efficient for generating a sequential list of numbers.
<?php
$given_number = 10;
for ($i = 1; $i <= $given_number; $i++) {
echo $i . "<br>";
}
?>