How can alternating row colors (zebra striping) be implemented in dynamically generated tables using PHP?

Alternating row colors, also known as zebra striping, can be implemented in dynamically generated tables using PHP by using a simple conditional statement to apply different CSS classes to odd and even rows. This can be achieved by iterating through the rows in the table and applying a CSS class based on whether the row index is even or odd.

```php
<?php
// Sample PHP code to generate a table with alternating row colors (zebra striping)

// Sample data for the table
$data = array(
    array("Name", "Age"),
    array("John", 25),
    array("Jane", 30),
    array("Mike", 22)
);

// Start the table
echo "<table>";

// Loop through the data and generate rows
foreach ($data as $index => $row) {
    // Apply different CSS class based on odd/even row index
    $class = ($index % 2 == 0) ? "even" : "odd";

    // Start row with CSS class
    echo "<tr class='$class'>";
    
    // Generate table cells
    foreach ($row as $cell) {
        echo "<td>$cell</td>";
    }

    // End row
    echo "</tr>";
}

// End the table
echo "</table>";
?>
```

In this code snippet, the CSS class "even" is applied to even rows and the CSS class "odd" is applied to odd rows, resulting in alternating row colors in the dynamically generated table.