Blogger Information
Blog 13
fans 0
comment 0
visits 9820
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
foreach循环遍历输出数组
樱风醉
Original
1318 people have browsed it
  1. echo '<style>table{border-collapse:collapse;}table,th, td{border: 1px solid black;text-align: center;}td{width: 170px;}</style>';
  2. echo '<table >';
  3. echo '<thead><tr><th>id</th><th>省/市/区</th><th>经度</th><th>纬度</th></tr></thead>';
  4. foreach ($arr as $province) {
  5. echo '<tr><th colspan="5">'.$province['area_name'].'</th></tr>';
  6. foreach ($province['son'] as $city) {
  7. echo '<tr><th>'.$city['area_id'].'</th><th>'.$city['area_name'].'</th><th>'.$city['lng'].'</th><th>'.$city['lat'].'</th></tr>';
  8. foreach ($city['son'] as $area) {
  9. echo '<tr><td>'.$area['area_id'].'</td><td>'.$area['area_name'].'</td><td>'.$area['lng'].'</td><td>'.$area['lat'].'</td></tr>';
  10. }
  11. }
  12. }
  13. echo'</table>';

效果图

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post