What are the benefits of using a Table-Helper for outputting multiple tables in PHP?

When outputting multiple tables in PHP, it can become cumbersome and repetitive to write the HTML markup for each table. Using a Table-Helper can simplify the process by providing a reusable function to generate tables with dynamic data. This can save time and make the code more maintainable and readable.

<?php

// Table-Helper function to output a table with dynamic data
function generate_table($data) {
    echo '<table>';
    foreach ($data as $row) {
        echo '<tr>';
        foreach ($row as $cell) {
            echo '<td>' . $cell . '</td>';
        }
        echo '</tr>';
    }
    echo '</table>';
}

// Example usage of the Table-Helper function
$table_data = [
    ['Name', 'Age', 'Country'],
    ['John', 25, 'USA'],
    ['Alice', 30, 'Canada'],
    ['Bob', 22, 'UK']
];

generate_table($table_data);

?>