foreach循环遍历输出数组
程序员文章站
2022-03-24 10:01:29
...
echo '<style>table{border-collapse:collapse;}table,th, td{border: 1px solid black;text-align: center;}td{width: 170px;}</style>';
echo '<table >';
echo '<thead><tr><th>id</th><th>省/市/区</th><th>经度</th><th>纬度</th></tr></thead>';
foreach ($arr as $province) {
echo '<tr><th colspan="5">'.$province['area_name'].'</th></tr>';
foreach ($province['son'] as $city) {
echo '<tr><th>'.$city['area_id'].'</th><th>'.$city['area_name'].'</th><th>'.$city['lng'].'</th><th>'.$city['lat'].'</th></tr>';
foreach ($city['son'] as $area) {
echo '<tr><td>'.$area['area_id'].'</td><td>'.$area['area_name'].'</td><td>'.$area['lng'].'</td><td>'.$area['lat'].'</td></tr>';
}
}
}
echo'</table>';
效果图
上一篇: mysql怎么实现查询并排序
下一篇: linux 不能输入中文怎么办