How can a multidimensional array be displayed in a table in PHP without overwriting values?

When displaying a multidimensional array in a table in PHP, you need to loop through each row and column of the array to populate the table cells. To avoid overwriting values, you can use nested loops to iterate through the array and display the values in the corresponding table cells.

<?php
// Sample multidimensional array
$array = array(
    array("John", "Doe", 30),
    array("Jane", "Smith", 25),
    array("Tom", "Brown", 35)
);

echo "<table border='1'>";
foreach ($array as $row) {
    echo "<tr>";
    foreach ($row as $value) {
        echo "<td>$value</td>";
    }
    echo "</tr>";
}
echo "</table>";
?>