In the provided PHP code, what improvements can be made to optimize the display of data in a more organized manner?
The issue with the provided PHP code is that the data is being displayed in a single line without any formatting, making it hard to read and understand. To optimize the display of data in a more organized manner, we can use HTML table tags to structure the data into rows and columns, making it easier to visualize and comprehend.
<?php
// Sample data array
$data = [
['John', 'Doe', 30],
['Jane', 'Smith', 25],
['Mike', 'Johnson', 35]
];
// Display data in a table format
echo '<table>';
echo '<tr><th>First Name</th><th>Last Name</th><th>Age</th></tr>';
foreach ($data as $row) {
echo '<tr>';
foreach ($row as $value) {
echo '<td>' . $value . '</td>';
}
echo '</tr>';
}
echo '</table>';
?>