- First of all get the headlines
- Then iterate thru the schools
- Output the columns with their contents
echo "<table>\n";
echo "<tr>";
foreach (array_keys(reset($city['schoolDetails'])) as $headline) {
echo "<th>$headline</th>";
}
echo "</tr>\n";
foreach ($city['schoolDetails'] as $school) {
echo "<tr>";
displayColumn($school);
echo "</tr>\n";
}
echo "</table>\n";
function displayColumn(array $array)
{
foreach ($array as $key => $value) {
echo "<td>";
if (is_array($value)) {
echo implode("<br>\n", $value);
} else {
echo $value;
}
echo "</td>";
}
}