What potential pitfalls should be considered when using a running counter in a PHP loop to determine even or odd data rows?

When using a running counter in a PHP loop to determine even or odd data rows, it's important to consider the starting index of the counter. If the counter starts at 0, then the first row will be considered even. To avoid this pitfall, you can start the counter at 1 instead of 0.

// Start the counter at 1 to correctly determine even or odd rows
$counter = 1;

foreach ($dataRows as $row) {
    if ($counter % 2 == 0) {
        // This is an even row
    } else {
        // This is an odd row
    }
    
    $counter++;
}