What are some best practices for using PHP loops to output numbers from 1 to 100 in rows of 10?

To output numbers from 1 to 100 in rows of 10 using PHP loops, you can use a for loop to iterate from 1 to 100 and use a counter to keep track of the number of elements output in each row. When the counter reaches 10, you can add a line break to start a new row.

<?php
// Initialize counter
$counter = 0;

// Loop from 1 to 100
for ($i = 1; $i <= 100; $i++) {
    // Output the number
    echo $i . " ";
    
    // Increment counter
    $counter++;
    
    // Add line break after every 10 numbers
    if ($counter % 10 == 0) {
        echo "<br>";
    }
}
?>