What is the best approach to display multiple arrays in a table in PHP?

When displaying multiple arrays in a table in PHP, you can use nested loops to iterate through each array and display the data in rows and columns of the table. You can use HTML table tags within the PHP code to structure the output in a tabular format. By properly formatting the data from each array within the table, you can present the information in an organized and visually appealing way.

<?php
// Sample arrays
$array1 = array("Name" => "John", "Age" => 30, "City" => "New York");
$array2 = array("Name" => "Jane", "Age" => 25, "City" => "Los Angeles");

// Display arrays in a table
echo "<table border='1'>";
echo "<tr><th>Name</th><th>Age</th><th>City</th></tr>";
foreach ([$array1, $array2] as $array) {
    echo "<tr>";
    foreach ($array as $value) {
        echo "<td>$value</td>";
    }
    echo "</tr>";
}
echo "</table>";
?>