博客列表 >使用php数组遍历及模拟数据制作一个省级、市级、区县信息详情表

使用php数组遍历及模拟数据制作一个省级、市级、区县信息详情表

超超多喝水
超超多喝水原创
2021年10月10日 23:55:32696浏览

使用 php 数组遍历及模拟数据制作一个省级、市级、区县信息详情表

  1. <?php
  2. // 模拟数据
  3. $arr = [
  4. [
  5. 'area_id' =>
  6. 110000, 'area_pid' => 0, 'area_name' => '北京', 'lng' => 116.405, 'lat' => 39.905, 'son' => [ [ 'area_id' => 110100, 'area_pid' => 110000,
  7. 'area_name' => '北京市', 'lng' => 116.405, 'lat' => 39.905, 'son' => [ [ 'area_id' => 110101, 'area_pid' => 110100, 'area_name' => '东城区',
  8. 'lng' => 116.41, 'lat' => 39.9316 ], [ 'area_id' => 110102, 'area_pid' => 110100, 'area_name' => '西城区', 'lng' => 116.36, 'lat' => 39.9305 ],
  9. [ 'area_id' => 110105, 'area_pid' => 110100, 'area_name' => '朝阳区', 'lng' => 116.485, 'lat' => 39.9484 ], [ 'area_id' => 110106, 'area_pid' =>
  10. 110100, 'area_name' => '丰台区', 'lng' => 116.286, 'lat' => 39.8585 ], [ 'area_id' => 110107, 'area_pid' => 110100, 'area_name' => '石景山区',
  11. 'lng' => 116.223, 'lat' => 39.9056 ], [ 'area_id' => 110108, 'area_pid' => 110100, 'area_name' => '海淀区', 'lng' => 116.298, 'lat' => 39.9593
  12. ], [ 'area_id' => 110109, 'area_pid' => 110100, 'area_name' => '门头沟区', 'lng' => 116.101, 'lat' => 39.9404 ], [ 'area_id' => 110111,
  13. 'area_pid' => 110100, 'area_name' => '房山区', 'lng' => 116.143, 'lat' => 39.7479 ], [ 'area_id' => 110112, 'area_pid' => 110100, 'area_name' =>
  14. '通州区', 'lng' => 116.657, 'lat' => 39.9097 ], [ 'area_id' => 110113, 'area_pid' => 110100, 'area_name' => '顺义区', 'lng' => 116.654, 'lat' =>
  15. 40.1302 ], [ 'area_id' => 110114, 'area_pid' => 110100, 'area_name' => '昌平区', 'lng' => 116.231, 'lat' => 40.2207 ], [ 'area_id' => 110115,
  16. 'area_pid' => 110100, 'area_name' => '大兴区', 'lng' => 116.341, 'lat' => 39.7267 ], [ 'area_id' => 110116, 'area_pid' => 110100, 'area_name' =>
  17. '怀柔区', 'lng' => 116.632, 'lat' => 40.316 ], [ 'area_id' => 110117, 'area_pid' => 110100, 'area_name' => '平谷区', 'lng' => 117.121, 'lat' =>
  18. 40.1406 ], [ 'area_id' => 110228, 'area_pid' => 110100, 'area_name' => '密云县', 'lng' => 116.843, 'lat' => 40.3762 ], [ 'area_id' => 110229,
  19. 'area_pid' => 110100, 'area_name' => '延庆县', 'lng' => 115.975, 'lat' => 40.4567 ] ] ] ] ], [ 'area_id' => 120000, 'area_pid' => 0, 'area_name'
  20. => '天津', 'lng' => 117.19, 'lat' => 39.1256, 'son' => [ [ 'area_id' => 120100, 'area_pid' => 120000, 'area_name' => '天津市', 'lng' => 117.19,
  21. 'lat' => 39.1256, 'son' => [ [ 'area_id' => 120101, 'area_pid' => 120100, 'area_name' => '和平区', 'lng' => 117.215, 'lat' => 39.1172 ], [
  22. 'area_id' => 120102, 'area_pid' => 120100, 'area_name' => '河东区', 'lng' => 117.226, 'lat' => 39.1232 ], [ 'area_id' => 120103, 'area_pid' =>
  23. 120100, 'area_name' => '河西区', 'lng' => 117.223, 'lat' => 39.1096 ], [ 'area_id' => 120104, 'area_pid' => 120100, 'area_name' => '南开区',
  24. 'lng' => 117.151, 'lat' => 39.1382 ], [ 'area_id' => 120105, 'area_pid' => 120100, 'area_name' => '河北区', 'lng' => 117.197, 'lat' => 39.1482
  25. ], [ 'area_id' => 120106, 'area_pid' => 120100, 'area_name' => '红桥区', 'lng' => 117.151, 'lat' => 39.1671 ], [ 'area_id' => 120110, 'area_pid'
  26. => 120100, 'area_name' => '东丽区', 'lng' => 117.314, 'lat' => 39.0863 ], [ 'area_id' => 120111, 'area_pid' => 120100, 'area_name' => '西青区',
  27. 'lng' => 117.009, 'lat' => 39.1412 ], [ 'area_id' => 120112, 'area_pid' => 120100, 'area_name' => '津南区', 'lng' => 117.385, 'lat' => 38.9914
  28. ], [ 'area_id' => 120113, 'area_pid' => 120100, 'area_name' => '北辰区', 'lng' => 117.132, 'lat' => 39.2213 ], [ 'area_id' => 120114, 'area_pid'
  29. => 120100, 'area_name' => '武清区', 'lng' => 117.044, 'lat' => 39.3842 ], [ 'area_id' => 120115, 'area_pid' => 120100, 'area_name' => '宝坻区',
  30. 'lng' => 117.31, 'lat' => 39.7176 ], [ 'area_id' => 120116, 'area_pid' => 120100, 'area_name' => '滨海新区', 'lng' => 117.702, 'lat' => 39.0267
  31. ], [ 'area_id' => 120221, 'area_pid' => 120100, 'area_name' => '宁河县', 'lng' => 117.826, 'lat' => 39.3305 ], [ 'area_id' => 120223, 'area_pid'
  32. => 120100, 'area_name' => '静海县', 'lng' => 116.974, 'lat' => 38.9458 ], [ 'area_id' => 120225, 'area_pid' => 120100, 'area_name' => '蓟县',
  33. 'lng' => 117.408, 'lat' => 40.0457 ] ] ] ] ], [ 'area_id' => 130000, 'area_pid' => 0, 'area_name' => '河北省', 'lng' => 114.502, 'lat' =>
  34. 38.0455, 'son' => [ [ 'area_id' => 130100, 'area_pid' => 130000, 'area_name' => '石家庄市', 'lng' => 114.502, 'lat' => 38.0455, 'son' => [ [
  35. 'area_id' => 130102, 'area_pid' => 130100, 'area_name' => '长安区', 'lng' => 114.539, 'lat' => 38.0367, ], [ 'area_id' => 130104, 'area_pid' =>
  36. 130100, 'area_name' => '桥西区', 'lng' => 114.47, 'lat' => 38.0322 ], [ 'area_id' => 130105, 'area_pid' => 130100, 'area_name' => '新华区',
  37. 'lng' => 114.463, 'lat' => 38.0509 ], [ 'area_id' => 130107, 'area_pid' => 130100, 'area_name' => '井陉矿区', 'lng' => 114.065, 'lat' => 38.0671
  38. ], [ 'area_id' => 130108, 'area_pid' => 130100, 'area_name' => '裕华区', 'lng' => 114.531, 'lat' => 38.006 ], [ 'area_id' => 130109, 'area_pid'
  39. => 130100, 'area_name' => '藁城区', 'lng' => 114.847, 'lat' => 38.0216 ], [ 'area_id' => 130110, 'area_pid' => 130100, 'area_name' => '鹿泉区',
  40. 'lng' => 114.313, 'lat' => 38.0878 ], [ 'area_id' => 130111, 'area_pid' => 130100, 'area_name' => '栾城区', 'lng' => 114.648, 'lat' => 37.9002
  41. ], [ 'area_id' => 130121, 'area_pid' => 130100, 'area_name' => '井陉县', 'lng' => 114.143, 'lat' => 38.0369 ], [ 'area_id' => 130123, 'area_pid'
  42. => 130100, 'area_name' => '正定县', 'lng' => 114.573, 'lat' => 38.1445 ], [ 'area_id' => 130125, 'area_pid' => 130100, 'area_name' => '行唐县',
  43. 'lng' => 114.553, 'lat' => 38.4365 ], [ 'area_id' => 130126, 'area_pid' => 130100, 'area_name' => '灵寿县', 'lng' => 114.383, 'lat' => 38.3084
  44. ], [ 'area_id' => 130127, 'area_pid' => 130100, 'area_name' => '高邑县', 'lng' => 114.611, 'lat' => 37.6156 ], [ 'area_id' => 130128, 'area_pid'
  45. => 130100, 'area_name' => '深泽县', 'lng' => 115.204, 'lat' => 38.1835 ], [ 'area_id' => 130129, 'area_pid' => 130100, 'area_name' => '赞皇县',
  46. 'lng' => 114.388, 'lat' => 37.6614 ], [ 'area_id' => 130130, 'area_pid' => 130100, 'area_name' => '无极县', 'lng' => 114.975, 'lat' => 38.1765
  47. ], [ 'area_id' => 130131, 'area_pid' => 130100, 'area_name' => '平山县', 'lng' => 114.186, 'lat' => 38.2599 ], [ 'area_id' => 130132, 'area_pid'
  48. => 130100, 'area_name' => '元氏县', 'lng' => 114.525, 'lat' => 37.7667 ], [ 'area_id' => 130133, 'area_pid' => 130100, 'area_name' => '赵县',
  49. 'lng' => 114.776, 'lat' => 37.7563 ], [ 'area_id' => 130181, 'area_pid' => 130100, 'area_name' => '辛集市', 'lng' => 115.206, 'lat' => 37.9408
  50. ], [ 'area_id' => 130183, 'area_pid' => 130100, 'area_name' => '晋州市', 'lng' => 115.043, 'lat' => 38.0313 ], [ 'area_id' => 130184, 'area_pid'
  51. => 130100, 'area_name' => '新乐市', 'lng' => 114.69, 'lat' => 38.3442 ] ] ], [ 'area_id' => 130200, 'area_pid' => 130000, 'area_name' =>
  52. '唐山市', 'lng' => 118.175, 'lat' => 39.6351, 'son' => [ [ 'area_id' => 130284, 'area_pid' => 130200, 'area_name' => '滦州市', 'lng' => '',
  53. 'lat' => '' ], [ 'area_id' => 130202, 'area_pid' => 130200, 'area_name' => '路南区', 'lng' => 118.154, 'lat' => 39.625, ], [ 'area_id' =>
  54. 130203, 'area_pid' => 130200, 'area_name' => '路北区', 'lng' => 118.201, 'lat' => 39.6244 ], [ 'area_id' => 130204, 'area_pid' => 130200,
  55. 'area_name' => '古冶区', 'lng' => 118.458, 'lat' => 39.7199 ], [ 'area_id' => 130205, 'area_pid' => 130200, 'area_name' => '开平区', 'lng' =>
  56. 118.262, 'lat' => 39.6713 ], [ 'area_id' => 130207, 'area_pid' => 130200, 'area_name' => '丰南区', 'lng' => 118.113, 'lat' => 39.5648 ], [
  57. 'area_id' => 130208, 'area_pid' => 130200, 'area_name' => '丰润区', 'lng' => 118.13, 'lat' => 39.8244 ], [ 'area_id' => 130209, 'area_pid' =>
  58. 130200, 'area_name' => '曹妃甸区', 'lng' => 118.46, 'lat' => 39.2731 ], [ 'area_id' => 130223, 'area_pid' => 130200, 'area_name' => '滦县',
  59. 'lng' => 118.703, 'lat' => 39.7406 ], [ 'area_id' => 130224, 'area_pid' => 130200, 'area_name' => '滦南县', 'lng' => 118.674, 'lat' => 39.5039
  60. ], [ 'area_id' => 130225, 'area_pid' => 130200, 'area_name' => '乐亭县', 'lng' => 118.912, 'lat' => 39.4256 ], [ 'area_id' => 130227, 'area_pid'
  61. => 130200, 'area_name' => '迁西县', 'lng' => 118.316, 'lat' => 40.1459 ], [ 'area_id' => 130229, 'area_pid' => 130200, 'area_name' => '玉田县',
  62. 'lng' => 117.739, 'lat' => 39.9005 ], [ 'area_id' => 130281, 'area_pid' => 130200, 'area_name' => '遵化市', 'lng' => 117.964, 'lat' => 40.1874
  63. ], [ 'area_id' => 130283, 'area_pid' => 130200, 'area_name' => '迁安市', 'lng' => 118.701, 'lat' => 39.9983 ] ] ], [ 'area_id' => 130300,
  64. 'area_pid' => 130000, 'area_name' => '秦皇岛市', 'lng' => 119.587, 'lat' => 39.9425, 'son' => [ [ 'area_id' => 130302, 'area_pid' => 130300,
  65. 'area_name' => '海港区', 'lng' => 119.61, 'lat' => 39.9345 ], [ 'area_id' => 130303, 'area_pid' => 130300, 'area_name' => '山海关区', 'lng' =>
  66. 119.776, 'lat' => 39.9787 ], [ 'area_id' => 130304, 'area_pid' => 130300, 'area_name' => '北戴河区', 'lng' => 119.484, 'lat' => 39.8341 ], [
  67. 'area_id' => 130321, 'area_pid' => 130300, 'area_name' => '青龙满族自治县', 'lng' => 118.952, 'lat' => 40.4074 ], [ 'area_id' => 130322,
  68. 'area_pid' => 130300, 'area_name' => '昌黎县', 'lng' => 119.166, 'lat' => 39.7088 ], [ 'area_id' => 130323, 'area_pid' => 130300, 'area_name' =>
  69. '抚宁县', 'lng' => 119.245, 'lat' => 39.8754 ], [ 'area_id' => 130324, 'area_pid' => 130300, 'area_name' => '卢龙县', 'lng' => 118.893, 'lat' =>
  70. 39.8918 ] ] ], [ 'area_id' => 130400, 'area_pid' => 130000, 'area_name' => '邯郸市', 'lng' => 114.491, 'lat' => 36.6123, 'son' => [ [ 'area_id'
  71. => 130402, 'area_pid' => 130400, 'area_name' => '邯山区', 'lng' => 114.484, 'lat' => 36.6001 ], [ 'area_id' => 130403, 'area_pid' => 130400,
  72. 'area_name' => '丛台区', 'lng' => 114.493, 'lat' => 36.6185 ], [ 'area_id' => 130404, 'area_pid' => 130400, 'area_name' => '复兴区', 'lng' =>
  73. 114.459, 'lat' => 36.6113 ], [ 'area_id' => 130406, 'area_pid' => 130400, 'area_name' => '峰峰矿区', 'lng' => 114.211, 'lat' => 36.4194 ], [
  74. 'area_id' => 130421, 'area_pid' => 130400, 'area_name' => '邯郸县', 'lng' => 114.531, 'lat' => 36.5938 ], [ 'area_id' => 130423, 'area_pid' =>
  75. 130400, 'area_name' => '临漳县', 'lng' => 114.619, 'lat' => 36.3346 ], [ 'area_id' => 130424, 'area_pid' => 130400, 'area_name' => '成安县',
  76. 'lng' => 114.67, 'lat' => 36.4441 ], [ 'area_id' => 130425, 'area_pid' => 130400, 'area_name' => '大名县', 'lng' => 115.154, 'lat' => 36.2799 ],
  77. [ 'area_id' => 130426, 'area_pid' => 130400, 'area_name' => '涉县', 'lng' => 113.692, 'lat' => 36.5807 ], [ 'area_id' => 130427, 'area_pid' =>
  78. 130400, 'area_name' => '磁县', 'lng' => 114.374, 'lat' => 36.3739 ], [ 'area_id' => 130428, 'area_pid' => 130400, 'area_name' => '肥乡县', 'lng'
  79. => 114.8, 'lat' => 36.5481 ], [ 'area_id' => 130429, 'area_pid' => 130400, 'area_name' => '永年县', 'lng' => 114.489, 'lat' => 36.7836 ], [
  80. 'area_id' => 130430, 'area_pid' => 130400, 'area_name' => '邱县', 'lng' => 115.174, 'lat' => 36.8208 ], [ 'area_id' => 130431, 'area_pid' =>
  81. 130400, 'area_name' => '鸡泽县', 'lng' => 114.874, 'lat' => 36.9237 ], [ 'area_id' => 130432, 'area_pid' => 130400, 'area_name' => '广平县',
  82. 'lng' => 114.947, 'lat' => 36.4805 ], [ 'area_id' => 130433, 'area_pid' => 130400, 'area_name' => '馆陶县', 'lng' => 115.299, 'lat' => 36.5372
  83. ], [ 'area_id' => 130434, 'area_pid' => 130400, 'area_name' => '魏县', 'lng' => 114.935, 'lat' => 36.3617 ], [ 'area_id' => 130435, 'area_pid'
  84. => 130400, 'area_name' => '曲周县', 'lng' => 114.952, 'lat' => 36.7767 ], [ 'area_id' => 130481, 'area_pid' => 130400, 'area_name' => '武安市',
  85. 'lng' => 114.202, 'lat' => 36.6928 ] ] ], [ 'area_id' => 130500, 'area_pid' => 130000, 'area_name' => '邢台市', 'lng' => 114.509, 'lat' =>
  86. 37.0682, 'son' => [ [ 'area_id' => 130502, 'area_pid' => 130500, 'area_name' => '桥东区', 'lng' => 114.507, 'lat' => 37.068 ], [ 'area_id' =>
  87. 130503, 'area_pid' => 130500, 'area_name' => '桥西区', 'lng' => 114.468, 'lat' => 37.0598 ], [ 'area_id' => 130521, 'area_pid' => 130500,
  88. 'area_name' => '邢台县', 'lng' => 114.566, 'lat' => 37.0456 ], [ 'area_id' => 130522, 'area_pid' => 130500, 'area_name' => '临城县', 'lng' =>
  89. 114.504, 'lat' => 37.4398 ], [ 'area_id' => 130523, 'area_pid' => 130500, 'area_name' => '内丘县', 'lng' => 114.512, 'lat' => 37.2867 ], [
  90. 'area_id' => 130524, 'area_pid' => 130500, 'area_name' => '柏乡县', 'lng' => 114.693, 'lat' => 37.4824 ], [ 'area_id' => 130525, 'area_pid' =>
  91. 130500, 'area_name' => '隆尧县', 'lng' => 114.776, 'lat' => 37.3535 ], [ 'area_id' => 130526, 'area_pid' => 130500, 'area_name' => '任县', 'lng'
  92. => 114.684, 'lat' => 37.1258 ], [ 'area_id' => 130527, 'area_pid' => 130500, 'area_name' => '南和县', 'lng' => 114.684, 'lat' => 37.0049 ], [
  93. 'area_id' => 130528, 'area_pid' => 130500, 'area_name' => '宁晋县', 'lng' => 114.921, 'lat' => 37.617 ], [ 'area_id' => 130529, 'area_pid' =>
  94. 130500, 'area_name' => '巨鹿县', 'lng' => 115.035, 'lat' => 37.218 ], [ 'area_id' => 130530, 'area_pid' => 130500, 'area_name' => '新河县',
  95. 'lng' => 115.25, 'lat' => 37.5272 ], [ 'area_id' => 130531, 'area_pid' => 130500, 'area_name' => '广宗县', 'lng' => 115.143, 'lat' => 37.0746 ],
  96. [ 'area_id' => 130532, 'area_pid' => 130500, 'area_name' => '平乡县', 'lng' => 115.03, 'lat' => 37.0632 ], [ 'area_id' => 130533, 'area_pid' =>
  97. 130500, 'area_name' => '威县', 'lng' => 115.264, 'lat' => 36.9768 ], [ 'area_id' => 130534, 'area_pid' => 130500, 'area_name' => '清河县', 'lng'
  98. => 115.665, 'lat' => 37.0712 ], [ 'area_id' => 130535, 'area_pid' => 130500, 'area_name' => '临西县', 'lng' => 115.501, 'lat' => 36.8708 ], [
  99. 'area_id' => 130581, 'area_pid' => 130500, 'area_name' => '南宫市', 'lng' => 115.391, 'lat' => 37.358 ], [ 'area_id' => 130582, 'area_pid' =>
  100. 130500, 'area_name' => '沙河市', 'lng' => 114.498, 'lat' => 36.8577 ] ] ], [ 'area_id' => 130600, 'area_pid' => 130000, 'area_name' => '保定市',
  101. 'lng' => 115.482, 'lat' => 38.8677, 'son' => [ [ 'area_id' => 130602, 'area_pid' => 130600, 'area_name' => '新市区', 'lng' => 115.459, 'lat' =>
  102. 38.8775 ], [ 'area_id' => 130603, 'area_pid' => 130600, 'area_name' => '北市区', 'lng' => 115.497, 'lat' => 38.8832 ], [ 'area_id' => 130604,
  103. 'area_pid' => 130600, 'area_name' => '南市区', 'lng' => 115.529, 'lat' => 38.8545 ], [ 'area_id' => 130621, 'area_pid' => 130600, 'area_name' =>
  104. '满城县', 'lng' => 115.323, 'lat' => 38.9497 ], [ 'area_id' => 130622, 'area_pid' => 130600, 'area_name' => '清苑县', 'lng' => 115.493, 'lat' =>
  105. 38.7671 ], [ 'area_id' => 130623, 'area_pid' => 130600, 'area_name' => '涞水县', 'lng' => 115.715, 'lat' => 39.394 ], [ 'area_id' => 130624,
  106. 'area_pid' => 130600, 'area_name' => '阜平县', 'lng' => 114.197, 'lat' => 38.8476 ], [ 'area_id' => 130625, 'area_pid' => 130600, 'area_name' =>
  107. '徐水县', 'lng' => 115.658, 'lat' => 39.021 ], [ 'area_id' => 130626, 'area_pid' => 130600, 'area_name' => '定兴县', 'lng' => 115.808, 'lat' =>
  108. 39.2631 ], [ 'area_id' => 130627, 'area_pid' => 130600, 'area_name' => '唐县', 'lng' => 114.985, 'lat' => 38.7451 ], [ 'area_id' => 130628,
  109. 'area_pid' => 130600, 'area_name' => '高阳县', 'lng' => 115.779, 'lat' => 38.7 ], [ 'area_id' => 130629, 'area_pid' => 130600, 'area_name' =>
  110. '容城县', 'lng' => 115.872, 'lat' => 39.0535 ], [ 'area_id' => 130630, 'area_pid' => 130600, 'area_name' => '涞源县', 'lng' => 114.691, 'lat' =>
  111. 39.3539 ], [ 'area_id' => 130631, 'area_pid' => 130600, 'area_name' => '望都县', 'lng' => 115.157, 'lat' => 38.71 ], [ 'area_id' => 130632,
  112. 'area_pid' => 130600, 'area_name' => '安新县', 'lng' => 115.936, 'lat' => 38.9353 ], [ 'area_id' => 130633, 'area_pid' => 130600, 'area_name' =>
  113. '易县', 'lng' => 115.498, 'lat' => 39.3489 ], [ 'area_id' => 130634, 'area_pid' => 130600, 'area_name' => '曲阳县', 'lng' => 114.701, 'lat' =>
  114. 38.6215 ], [ 'area_id' => 130635, 'area_pid' => 130600, 'area_name' => '蠡县', 'lng' => 115.577, 'lat' => 38.4897 ], [ 'area_id' => 130636,
  115. 'area_pid' => 130600, 'area_name' => '顺平县', 'lng' => 115.135, 'lat' => 38.8385 ], [ 'area_id' => 130637, 'area_pid' => 130600, 'area_name' =>
  116. '博野县', 'lng' => 115.47, 'lat' => 38.4564 ], [ 'area_id' => 130638, 'area_pid' => 130600, 'area_name' => '雄县', 'lng' => 116.109, 'lat' =>
  117. 38.9944 ], [ 'area_id' => 130681, 'area_pid' => 130600, 'area_name' => '涿州市', 'lng' => 115.981, 'lat' => 39.4862 ], [ 'area_id' => 130682,
  118. 'area_pid' => 130600, 'area_name' => '定州市', 'lng' => 114.99, 'lat' => 38.5162 ], [ 'area_id' => 130683, 'area_pid' => 130600, 'area_name' =>
  119. '安国市', 'lng' => 115.323, 'lat' => 38.4139 ], [ 'area_id' => 130684, 'area_pid' => 130600, 'area_name' => '高碑店市', 'lng' => 115.874, 'lat'
  120. => 39.3265 ] ] ], [ 'area_id' => 130700, 'area_pid' => 130000, 'area_name' => '张家口市', 'lng' => 114.884, 'lat' => 40.8119, 'son' => [ [
  121. 'area_id' => 130702, 'area_pid' => 130700, 'area_name' => '桥东区', 'lng' => 114.894, 'lat' => 40.7884 ], [ 'area_id' => 130703, 'area_pid' =>
  122. 130700, 'area_name' => '桥西区', 'lng' => 114.87, 'lat' => 40.8195 ], [ 'area_id' => 130705, 'area_pid' => 130700, 'area_name' => '宣化区',
  123. 'lng' => 115.065, 'lat' => 40.6096 ], [ 'area_id' => 130706, 'area_pid' => 130700, 'area_name' => '下花园区', 'lng' => 115.287, 'lat' => 40.5024
  124. ], [ 'area_id' => 130721, 'area_pid' => 130700, 'area_name' => '宣化县', 'lng' => 115.155, 'lat' => 40.5662 ], [ 'area_id' => 130722, 'area_pid'
  125. => 130700, 'area_name' => '张北县', 'lng' => 114.714, 'lat' => 41.1598 ], [ 'area_id' => 130723, 'area_pid' => 130700, 'area_name' => '康保县',
  126. 'lng' => 114.6, 'lat' => 41.8522 ], [ 'area_id' => 130724, 'area_pid' => 130700, 'area_name' => '沽源县', 'lng' => 115.689, 'lat' => 41.6696 ],
  127. [ 'area_id' => 130725, 'area_pid' => 130700, 'area_name' => '尚义县', 'lng' => 113.971, 'lat' => 41.0778 ], [ 'area_id' => 130726, 'area_pid' =>
  128. 130700, 'area_name' => '蔚县', 'lng' => 114.589, 'lat' => 39.8407 ], [ 'area_id' => 130727, 'area_pid' => 130700, 'area_name' => '阳原县', 'lng'
  129. => 114.151, 'lat' => 40.1036 ], [ 'area_id' => 130728, 'area_pid' => 130700, 'area_name' => '怀安县', 'lng' => 114.386, 'lat' => 40.6743 ], [
  130. 'area_id' => 130729, 'area_pid' => 130700, 'area_name' => '万全县', 'lng' => 114.741, 'lat' => 40.7669 ], [ 'area_id' => 130730, 'area_pid' =>
  131. 130700, 'area_name' => '怀来县', 'lng' => 115.518, 'lat' => 40.4154 ], [ 'area_id' => 130731, 'area_pid' => 130700, 'area_name' => '涿鹿县',
  132. 'lng' => 115.224, 'lat' => 40.3764 ], [ 'area_id' => 130732, 'area_pid' => 130700, 'area_name' => '赤城县', 'lng' => 115.832, 'lat' => 40.9144
  133. ], [ 'area_id' => 130733, 'area_pid' => 130700, 'area_name' => '崇礼县', 'lng' => 115.28, 'lat' => 40.9752 ] ] ], [ 'area_id' => 130800,
  134. 'area_pid' => 130000, 'area_name' => '承德市', 'lng' => 117.939, 'lat' => 40.9762, 'son' => [ [ 'area_id' => 130802, 'area_pid' => 130800,
  135. 'area_name' => '双桥区', 'lng' => 117.943, 'lat' => 40.9747 ], [ 'area_id' => 130803, 'area_pid' => 130800, 'area_name' => '双滦区', 'lng' =>
  136. 117.745, 'lat' => 40.9538 ], [ 'area_id' => 130804, 'area_pid' => 130800, 'area_name' => '鹰手营子矿区', 'lng' => 117.66, 'lat' => 40.5474 ], [
  137. 'area_id' => 130821, 'area_pid' => 130800, 'area_name' => '承德县', 'lng' => 118.176, 'lat' => 40.7699 ], [ 'area_id' => 130822, 'area_pid' =>
  138. 130800, 'area_name' => '兴隆县', 'lng' => 117.501, 'lat' => 40.4171 ], [ 'area_id' => 130823, 'area_pid' => 130800, 'area_name' => '平泉县',
  139. 'lng' => 118.702, 'lat' => 41.0184 ], [ 'area_id' => 130824, 'area_pid' => 130800, 'area_name' => '滦平县', 'lng' => 117.333, 'lat' => 40.9415
  140. ], [ 'area_id' => 130825, 'area_pid' => 130800, 'area_name' => '隆化县', 'lng' => 117.73, 'lat' => 41.3141 ], [ 'area_id' => 130826, 'area_pid'
  141. => 130800, 'area_name' => '丰宁满族自治县', 'lng' => 116.649, 'lat' => 41.2048 ], [ 'area_id' => 130827, 'area_pid' => 130800, 'area_name' =>
  142. '宽城满族自治县', 'lng' => 118.492, 'lat' => 40.6083 ], [ 'area_id' => 130828, 'area_pid' => 130800, 'area_name' => '围场满族蒙古族自治县',
  143. 'lng' => 117.76, 'lat' => 41.9437 ] ] ], [ 'area_id' => 130900, 'area_pid' => 130000, 'area_name' => '沧州市', 'lng' => 116.857, 'lat' =>
  144. 38.3106, 'son' => [ [ 'area_id' => 130902, 'area_pid' => 130900, 'area_name' => '新华区', 'lng' => 116.866, 'lat' => 38.3144 ], [ 'area_id' =>
  145. 130903, 'area_pid' => 130900, 'area_name' => '运河区', 'lng' => 116.857, 'lat' => 38.3135 ], [ 'area_id' => 130921, 'area_pid' => 130900,
  146. 'area_name' => '沧县', 'lng' => 116.878, 'lat' => 38.2936 ], [ 'area_id' => 130922, 'area_pid' => 130900, 'area_name' => '青县', 'lng' =>
  147. 116.803, 'lat' => 38.5835 ], [ 'area_id' => 130923, 'area_pid' => 130900, 'area_name' => '东光县', 'lng' => 116.537, 'lat' => 37.8857 ], [
  148. 'area_id' => 130924, 'area_pid' => 130900, 'area_name' => '海兴县', 'lng' => 117.498, 'lat' => 38.1396 ], [ 'area_id' => 130925, 'area_pid' =>
  149. 130900, 'area_name' => '盐山县', 'lng' => 117.231, 'lat' => 38.0565 ], [ 'area_id' => 130926, 'area_pid' => 130900, 'area_name' => '肃宁县',
  150. 'lng' => 115.83, 'lat' => 38.4227 ], [ 'area_id' => 130927, 'area_pid' => 130900, 'area_name' => '南皮县', 'lng' => 116.702, 'lat' => 38.0411 ],
  151. [ 'area_id' => 130928, 'area_pid' => 130900, 'area_name' => '吴桥县', 'lng' => 116.385, 'lat' => 37.6255 ], [ 'area_id' => 130929, 'area_pid' =>
  152. 130900, 'area_name' => '献县', 'lng' => 116.127, 'lat' => 38.1923 ], [ 'area_id' => 130930, 'area_pid' => 130900, 'area_name' =>
  153. '孟村回族自治县', 'lng' => 117.104, 'lat' => 38.0534 ], [ 'area_id' => 130981, 'area_pid' => 130900, 'area_name' => '泊头市', 'lng' => 116.578,
  154. 'lat' => 38.0836 ], [ 'area_id' => 130982, 'area_pid' => 130900, 'area_name' => '任丘市', 'lng' => 116.103, 'lat' => 38.7112 ], [ 'area_id' =>
  155. 130983, 'area_pid' => 130900, 'area_name' => '黄骅市', 'lng' => 117.339, 'lat' => 38.3706 ], [ 'area_id' => 130984, 'area_pid' => 130900,
  156. 'area_name' => '河间市', 'lng' => 116.099, 'lat' => 38.4455 ] ] ], [ 'area_id' => 131000, 'area_pid' => 130000, 'area_name' => '廊坊市', 'lng'
  157. => 116.714, 'lat' => 39.5292, 'son' => [ [ 'area_id' => 131002, 'area_pid' => 131000, 'area_name' => '安次区', 'lng' => 116.703, 'lat' =>
  158. 39.5206 ], [ 'area_id' => 131003, 'area_pid' => 131000, 'area_name' => '广阳区', 'lng' => 116.711, 'lat' => 39.5228 ], [ 'area_id' => 131022,
  159. 'area_pid' => 131000, 'area_name' => '固安县', 'lng' => 116.299, 'lat' => 39.4383 ], [ 'area_id' => 131023, 'area_pid' => 131000, 'area_name' =>
  160. '永清县', 'lng' => 116.501, 'lat' => 39.3207 ], [ 'area_id' => 131024, 'area_pid' => 131000, 'area_name' => '香河县', 'lng' => 117.006, 'lat' =>
  161. 39.7613 ], [ 'area_id' => 131025, 'area_pid' => 131000, 'area_name' => '大城县', 'lng' => 116.654, 'lat' => 38.7053 ], [ 'area_id' => 131026,
  162. 'area_pid' => 131000, 'area_name' => '文安县', 'lng' => 116.458, 'lat' => 38.8732 ], [ 'area_id' => 131028, 'area_pid' => 131000, 'area_name' =>
  163. '大厂回族自治县', 'lng' => 116.989, 'lat' => 39.8865 ], [ 'area_id' => 131081, 'area_pid' => 131000, 'area_name' => '霸州市', 'lng' => 116.392,
  164. 'lat' => 39.1257 ], [ 'area_id' => 131082, 'area_pid' => 131000, 'area_name' => '三河市', 'lng' => 117.072, 'lat' => 39.9836 ] ] ], [ 'area_id'
  165. => 131100, 'area_pid' => 130000, 'area_name' => '衡水市', 'lng' => 115.666, 'lat' => 37.7351, 'son' => [ [ 'area_id' => 131102, 'area_pid' =>
  166. 131100, 'area_name' => '桃城区', 'lng' => 115.675, 'lat' => 37.735, ], [ 'area_id' => 131121, 'area_pid' => 131100, 'area_name' => '枣强县',
  167. 'lng' => 115.726, 'lat' => 37.5103 ], [ 'area_id' => 131122, 'area_pid' => 131100, 'area_name' => '武邑县', 'lng' => 115.887, 'lat' => 37.8018
  168. ], [ 'area_id' => 131123, 'area_pid' => 131100, 'area_name' => '武强县', 'lng' => 115.982, 'lat' => 38.0414 ], [ 'area_id' => 131124, 'area_pid'
  169. => 131100, 'area_name' => '饶阳县', 'lng' => 115.726, 'lat' => 38.2353 ], [ 'area_id' => 131125, 'area_pid' => 131100, 'area_name' => '安平县',
  170. 'lng' => 115.519, 'lat' => 38.2339 ], [ 'area_id' => 131126, 'area_pid' => 131100, 'area_name' => '故城县', 'lng' => 115.971, 'lat' => 37.3477
  171. ], [ 'area_id' => 131127, 'area_pid' => 131100, 'area_name' => '景县', 'lng' => 116.269, 'lat' => 37.6926 ], [ 'area_id' => 131128, 'area_pid'
  172. => 131100, 'area_name' => '阜城县', 'lng' => 116.144, 'lat' => 37.8688 ], [ 'area_id' => 131181, 'area_pid' => 131100, 'area_name' => '冀州市',
  173. 'lng' => 115.579, 'lat' => 37.5508 ], [ 'area_id' => 131182, 'area_pid' => 131100, 'area_name' => '深州市', 'lng' => 115.56, 'lat' => 38.0011 ]
  174. ] ] ] ] ]; ?>
  175. <!DOCTYPE html>
  176. <html lang="zh-CN">
  177. <head>
  178. <meta charset="UTF-8" />
  179. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  180. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  181. <style>
  182. th,
  183. td {
  184. border: 1px solid;
  185. }
  186. table {
  187. background-color: hotpink;
  188. border-collapse: collapse;
  189. }
  190. </style>
  191. <title>省市区信息表</title>
  192. </head>
  193. <body>
  194. <div class="box">
  195. <table class="province">
  196. <caption>
  197. 省级信息表
  198. </caption>
  199. <thead>
  200. <tr>
  201. <th>省级行政区划代码</th>
  202. <th>省名称</th>
  203. <th>经度</th>
  204. <th>纬度</th>
  205. </tr>
  206. </thead>
  207. <tbody>
  208. <?php
  209. //一次遍历出第一级信息:省级信息
  210. foreach ( $arr as $val ) {
  211. // echo'<pre>'; // print_r( $val ); ?>
  212. <tr>
  213. <td><?php echo $val['area_id'] ?></td>
  214. <td><?php echo $val['area_name'] ?></td>
  215. <td><?php echo $val['lng'] ?></td>
  216. <td><?php echo $val['lat'] ?></td>
  217. </tr>
  218. <?php }
  219. ?>
  220. </tbody>
  221. </table>
  222. <table class="city">
  223. <caption>
  224. 市级信息表
  225. </caption>
  226. <thead>
  227. <tr>
  228. <th>省级行政区划代码</th>
  229. <th>省名称</th>
  230. <th>市级行政区划代码</th>
  231. <th>市名称</th>
  232. <th>经度</th>
  233. <th>纬度</th>
  234. </tr>
  235. </thead>
  236. <tbody>
  237. <?php
  238. foreach ( $arr as $val ) {
  239. // echo'<pre>'; print_r( $val["son"] );
  240. //二次遍历出第二级信息:城市信息
  241. foreach($val["son"] as $city){
  242. // echo'<pre>';
  243. // print_r($city);
  244. ?>
  245. <tr>
  246. <td><?php echo $val['area_id'] ?></td>
  247. <td><?php echo $val['area_name'] ?></td>
  248. <td><?php echo $city['area_id'] ?></td>
  249. <td><?php echo $city['area_name'] ?></td>
  250. <td><?php echo $city['lng'] ?></td>
  251. <td><?php echo $city['lat'] ?></td>
  252. </tr>
  253. <?php }}
  254. ?>
  255. </tbody>
  256. </table>
  257. <table class="county">
  258. <caption>
  259. 区/县/地级市信息表
  260. </caption>
  261. <thead>
  262. <tr>
  263. <th>省级行政区划代码</th>
  264. <th>省名称</th>
  265. <th>市级行政区划代码</th>
  266. <th>市名称</th>
  267. <th>区/县/地级市级行政区划代码</th>
  268. <th>区/县/地级市名称</th>
  269. <th>经度</th>
  270. <th>纬度</th>
  271. </tr>
  272. </thead>
  273. <tbody>
  274. <?php
  275. foreach ( $arr as $val ) {
  276. // echo'<pre>'; print_r( $val["son"] );
  277. foreach($val["son"] as $city){
  278. //三次遍历出第三级信息:区县信息
  279. foreach($city["son"] as $county){
  280. // echo'<pre>';
  281. // print_r($county);
  282. ?>
  283. <tr>
  284. <td><?php echo $val['area_id'] ?></td>
  285. <td><?php echo $val['area_name'] ?></td>
  286. <td><?php echo $city['area_id'] ?></td>
  287. <td><?php echo $city['area_name'] ?></td>
  288. <td><?php echo $county['area_id'] ?></td>
  289. <td><?php echo $county['area_name'] ?></td>
  290. <td><?php echo $county['lng'] ?></td>
  291. <td><?php echo $county['lat'] ?></td>
  292. </tr>
  293. <?php }}}
  294. ?>
  295. </tbody>
  296. </table>
  297. </div>
  298. </body>
  299. </html>

最终实现效果:
省级
市级
区县

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议