How can the PHP code be modified to add a <br> tag after every 10th data record instead of after each record?

To add a <br> tag after every 10th data record instead of after each record, we can introduce a counter variable that increments with each record. When the counter reaches 10, we add the <br> tag and reset the counter to 0. This way, the <br> tag will only be added after every 10th record.

&lt;?php
$counter = 0;

foreach ($data_records as $record) {
    // Output the data record here
    
    $counter++;
    if ($counter == 10) {
        echo &quot;&lt;br&gt;&quot;;
        $counter = 0;
    }
}
?&gt;