What are some best practices for using the modulo operator in PHP to style alternating rows?

When styling alternating rows in a table using PHP, the modulo operator (%) can be used to determine if a row is even or odd. By checking if the row index modulo 2 is equal to 0, we can apply different styles to even and odd rows.

<table>
<?php
for ($i = 0; $i < 10; $i++) {
    if ($i % 2 == 0) {
        echo '<tr style="background-color: #f0f0f0;">';
    } else {
        echo '<tr style="background-color: #ffffff;">';
    }
    echo '<td>Row ' . $i . '</td>';
    echo '</tr>';
}
?>
</table>