What are some potential solutions for displaying data in 5 columns and moving to a new row after every 5 entries in PHP?

When displaying data in 5 columns and needing to move to a new row after every 5 entries, one solution is to use a counter to keep track of the number of entries displayed. When the counter reaches 5, insert a line break to move to the next row.

<?php
$data = array("entry1", "entry2", "entry3", "entry4", "entry5", "entry6", "entry7", "entry8", "entry9", "entry10");

echo "<table>";
$count = 0;
foreach ($data as $entry) {
    if ($count % 5 == 0) {
        echo "<tr>";
    }
    echo "<td>$entry</td>";
    $count++;
    if ($count % 5 == 0) {
        echo "</tr>";
    }
}
echo "</table>";
?>