使用 php 数组遍历及模拟数据制作一个省级、市级、区县信息详情表
<?php
// 模拟数据
$arr = [
[
'area_id' =>
110000, 'area_pid' => 0, 'area_name' => '北京', 'lng' => 116.405, 'lat' => 39.905, 'son' => [ [ 'area_id' => 110100, 'area_pid' => 110000,
'area_name' => '北京市', 'lng' => 116.405, 'lat' => 39.905, 'son' => [ [ 'area_id' => 110101, 'area_pid' => 110100, 'area_name' => '东城区',
'lng' => 116.41, 'lat' => 39.9316 ], [ 'area_id' => 110102, 'area_pid' => 110100, 'area_name' => '西城区', 'lng' => 116.36, 'lat' => 39.9305 ],
[ 'area_id' => 110105, 'area_pid' => 110100, 'area_name' => '朝阳区', 'lng' => 116.485, 'lat' => 39.9484 ], [ 'area_id' => 110106, 'area_pid' =>
110100, 'area_name' => '丰台区', 'lng' => 116.286, 'lat' => 39.8585 ], [ 'area_id' => 110107, 'area_pid' => 110100, 'area_name' => '石景山区',
'lng' => 116.223, 'lat' => 39.9056 ], [ 'area_id' => 110108, 'area_pid' => 110100, 'area_name' => '海淀区', 'lng' => 116.298, 'lat' => 39.9593
], [ 'area_id' => 110109, 'area_pid' => 110100, 'area_name' => '门头沟区', 'lng' => 116.101, 'lat' => 39.9404 ], [ 'area_id' => 110111,
'area_pid' => 110100, 'area_name' => '房山区', 'lng' => 116.143, 'lat' => 39.7479 ], [ 'area_id' => 110112, 'area_pid' => 110100, 'area_name' =>
'通州区', 'lng' => 116.657, 'lat' => 39.9097 ], [ 'area_id' => 110113, 'area_pid' => 110100, 'area_name' => '顺义区', 'lng' => 116.654, 'lat' =>
40.1302 ], [ 'area_id' => 110114, 'area_pid' => 110100, 'area_name' => '昌平区', 'lng' => 116.231, 'lat' => 40.2207 ], [ 'area_id' => 110115,
'area_pid' => 110100, 'area_name' => '大兴区', 'lng' => 116.341, 'lat' => 39.7267 ], [ 'area_id' => 110116, 'area_pid' => 110100, 'area_name' =>
'怀柔区', 'lng' => 116.632, 'lat' => 40.316 ], [ 'area_id' => 110117, 'area_pid' => 110100, 'area_name' => '平谷区', 'lng' => 117.121, 'lat' =>
40.1406 ], [ 'area_id' => 110228, 'area_pid' => 110100, 'area_name' => '密云县', 'lng' => 116.843, 'lat' => 40.3762 ], [ 'area_id' => 110229,
'area_pid' => 110100, 'area_name' => '延庆县', 'lng' => 115.975, 'lat' => 40.4567 ] ] ] ] ], [ 'area_id' => 120000, 'area_pid' => 0, 'area_name'
=> '天津', 'lng' => 117.19, 'lat' => 39.1256, 'son' => [ [ 'area_id' => 120100, 'area_pid' => 120000, 'area_name' => '天津市', 'lng' => 117.19,
'lat' => 39.1256, 'son' => [ [ 'area_id' => 120101, 'area_pid' => 120100, 'area_name' => '和平区', 'lng' => 117.215, 'lat' => 39.1172 ], [
'area_id' => 120102, 'area_pid' => 120100, 'area_name' => '河东区', 'lng' => 117.226, 'lat' => 39.1232 ], [ 'area_id' => 120103, 'area_pid' =>
120100, 'area_name' => '河西区', 'lng' => 117.223, 'lat' => 39.1096 ], [ 'area_id' => 120104, 'area_pid' => 120100, 'area_name' => '南开区',
'lng' => 117.151, 'lat' => 39.1382 ], [ 'area_id' => 120105, 'area_pid' => 120100, 'area_name' => '河北区', 'lng' => 117.197, 'lat' => 39.1482
], [ 'area_id' => 120106, 'area_pid' => 120100, 'area_name' => '红桥区', 'lng' => 117.151, 'lat' => 39.1671 ], [ 'area_id' => 120110, 'area_pid'
=> 120100, 'area_name' => '东丽区', 'lng' => 117.314, 'lat' => 39.0863 ], [ 'area_id' => 120111, 'area_pid' => 120100, 'area_name' => '西青区',
'lng' => 117.009, 'lat' => 39.1412 ], [ 'area_id' => 120112, 'area_pid' => 120100, 'area_name' => '津南区', 'lng' => 117.385, 'lat' => 38.9914
], [ 'area_id' => 120113, 'area_pid' => 120100, 'area_name' => '北辰区', 'lng' => 117.132, 'lat' => 39.2213 ], [ 'area_id' => 120114, 'area_pid'
=> 120100, 'area_name' => '武清区', 'lng' => 117.044, 'lat' => 39.3842 ], [ 'area_id' => 120115, 'area_pid' => 120100, 'area_name' => '宝坻区',
'lng' => 117.31, 'lat' => 39.7176 ], [ 'area_id' => 120116, 'area_pid' => 120100, 'area_name' => '滨海新区', 'lng' => 117.702, 'lat' => 39.0267
], [ 'area_id' => 120221, 'area_pid' => 120100, 'area_name' => '宁河县', 'lng' => 117.826, 'lat' => 39.3305 ], [ 'area_id' => 120223, 'area_pid'
=> 120100, 'area_name' => '静海县', 'lng' => 116.974, 'lat' => 38.9458 ], [ 'area_id' => 120225, 'area_pid' => 120100, 'area_name' => '蓟县',
'lng' => 117.408, 'lat' => 40.0457 ] ] ] ] ], [ 'area_id' => 130000, 'area_pid' => 0, 'area_name' => '河北省', 'lng' => 114.502, 'lat' =>
38.0455, 'son' => [ [ 'area_id' => 130100, 'area_pid' => 130000, 'area_name' => '石家庄市', 'lng' => 114.502, 'lat' => 38.0455, 'son' => [ [
'area_id' => 130102, 'area_pid' => 130100, 'area_name' => '长安区', 'lng' => 114.539, 'lat' => 38.0367, ], [ 'area_id' => 130104, 'area_pid' =>
130100, 'area_name' => '桥西区', 'lng' => 114.47, 'lat' => 38.0322 ], [ 'area_id' => 130105, 'area_pid' => 130100, 'area_name' => '新华区',
'lng' => 114.463, 'lat' => 38.0509 ], [ 'area_id' => 130107, 'area_pid' => 130100, 'area_name' => '井陉矿区', 'lng' => 114.065, 'lat' => 38.0671
], [ 'area_id' => 130108, 'area_pid' => 130100, 'area_name' => '裕华区', 'lng' => 114.531, 'lat' => 38.006 ], [ 'area_id' => 130109, 'area_pid'
=> 130100, 'area_name' => '藁城区', 'lng' => 114.847, 'lat' => 38.0216 ], [ 'area_id' => 130110, 'area_pid' => 130100, 'area_name' => '鹿泉区',
'lng' => 114.313, 'lat' => 38.0878 ], [ 'area_id' => 130111, 'area_pid' => 130100, 'area_name' => '栾城区', 'lng' => 114.648, 'lat' => 37.9002
], [ 'area_id' => 130121, 'area_pid' => 130100, 'area_name' => '井陉县', 'lng' => 114.143, 'lat' => 38.0369 ], [ 'area_id' => 130123, 'area_pid'
=> 130100, 'area_name' => '正定县', 'lng' => 114.573, 'lat' => 38.1445 ], [ 'area_id' => 130125, 'area_pid' => 130100, 'area_name' => '行唐县',
'lng' => 114.553, 'lat' => 38.4365 ], [ 'area_id' => 130126, 'area_pid' => 130100, 'area_name' => '灵寿县', 'lng' => 114.383, 'lat' => 38.3084
], [ 'area_id' => 130127, 'area_pid' => 130100, 'area_name' => '高邑县', 'lng' => 114.611, 'lat' => 37.6156 ], [ 'area_id' => 130128, 'area_pid'
=> 130100, 'area_name' => '深泽县', 'lng' => 115.204, 'lat' => 38.1835 ], [ 'area_id' => 130129, 'area_pid' => 130100, 'area_name' => '赞皇县',
'lng' => 114.388, 'lat' => 37.6614 ], [ 'area_id' => 130130, 'area_pid' => 130100, 'area_name' => '无极县', 'lng' => 114.975, 'lat' => 38.1765
], [ 'area_id' => 130131, 'area_pid' => 130100, 'area_name' => '平山县', 'lng' => 114.186, 'lat' => 38.2599 ], [ 'area_id' => 130132, 'area_pid'
=> 130100, 'area_name' => '元氏县', 'lng' => 114.525, 'lat' => 37.7667 ], [ 'area_id' => 130133, 'area_pid' => 130100, 'area_name' => '赵县',
'lng' => 114.776, 'lat' => 37.7563 ], [ 'area_id' => 130181, 'area_pid' => 130100, 'area_name' => '辛集市', 'lng' => 115.206, 'lat' => 37.9408
], [ 'area_id' => 130183, 'area_pid' => 130100, 'area_name' => '晋州市', 'lng' => 115.043, 'lat' => 38.0313 ], [ 'area_id' => 130184, 'area_pid'
=> 130100, 'area_name' => '新乐市', 'lng' => 114.69, 'lat' => 38.3442 ] ] ], [ 'area_id' => 130200, 'area_pid' => 130000, 'area_name' =>
'唐山市', 'lng' => 118.175, 'lat' => 39.6351, 'son' => [ [ 'area_id' => 130284, 'area_pid' => 130200, 'area_name' => '滦州市', 'lng' => '',
'lat' => '' ], [ 'area_id' => 130202, 'area_pid' => 130200, 'area_name' => '路南区', 'lng' => 118.154, 'lat' => 39.625, ], [ 'area_id' =>
130203, 'area_pid' => 130200, 'area_name' => '路北区', 'lng' => 118.201, 'lat' => 39.6244 ], [ 'area_id' => 130204, 'area_pid' => 130200,
'area_name' => '古冶区', 'lng' => 118.458, 'lat' => 39.7199 ], [ 'area_id' => 130205, 'area_pid' => 130200, 'area_name' => '开平区', 'lng' =>
118.262, 'lat' => 39.6713 ], [ 'area_id' => 130207, 'area_pid' => 130200, 'area_name' => '丰南区', 'lng' => 118.113, 'lat' => 39.5648 ], [
'area_id' => 130208, 'area_pid' => 130200, 'area_name' => '丰润区', 'lng' => 118.13, 'lat' => 39.8244 ], [ 'area_id' => 130209, 'area_pid' =>
130200, 'area_name' => '曹妃甸区', 'lng' => 118.46, 'lat' => 39.2731 ], [ 'area_id' => 130223, 'area_pid' => 130200, 'area_name' => '滦县',
'lng' => 118.703, 'lat' => 39.7406 ], [ 'area_id' => 130224, 'area_pid' => 130200, 'area_name' => '滦南县', 'lng' => 118.674, 'lat' => 39.5039
], [ 'area_id' => 130225, 'area_pid' => 130200, 'area_name' => '乐亭县', 'lng' => 118.912, 'lat' => 39.4256 ], [ 'area_id' => 130227, 'area_pid'
=> 130200, 'area_name' => '迁西县', 'lng' => 118.316, 'lat' => 40.1459 ], [ 'area_id' => 130229, 'area_pid' => 130200, 'area_name' => '玉田县',
'lng' => 117.739, 'lat' => 39.9005 ], [ 'area_id' => 130281, 'area_pid' => 130200, 'area_name' => '遵化市', 'lng' => 117.964, 'lat' => 40.1874
], [ 'area_id' => 130283, 'area_pid' => 130200, 'area_name' => '迁安市', 'lng' => 118.701, 'lat' => 39.9983 ] ] ], [ 'area_id' => 130300,
'area_pid' => 130000, 'area_name' => '秦皇岛市', 'lng' => 119.587, 'lat' => 39.9425, 'son' => [ [ 'area_id' => 130302, 'area_pid' => 130300,
'area_name' => '海港区', 'lng' => 119.61, 'lat' => 39.9345 ], [ 'area_id' => 130303, 'area_pid' => 130300, 'area_name' => '山海关区', 'lng' =>
119.776, 'lat' => 39.9787 ], [ 'area_id' => 130304, 'area_pid' => 130300, 'area_name' => '北戴河区', 'lng' => 119.484, 'lat' => 39.8341 ], [
'area_id' => 130321, 'area_pid' => 130300, 'area_name' => '青龙满族自治县', 'lng' => 118.952, 'lat' => 40.4074 ], [ 'area_id' => 130322,
'area_pid' => 130300, 'area_name' => '昌黎县', 'lng' => 119.166, 'lat' => 39.7088 ], [ 'area_id' => 130323, 'area_pid' => 130300, 'area_name' =>
'抚宁县', 'lng' => 119.245, 'lat' => 39.8754 ], [ 'area_id' => 130324, 'area_pid' => 130300, 'area_name' => '卢龙县', 'lng' => 118.893, 'lat' =>
39.8918 ] ] ], [ 'area_id' => 130400, 'area_pid' => 130000, 'area_name' => '邯郸市', 'lng' => 114.491, 'lat' => 36.6123, 'son' => [ [ 'area_id'
=> 130402, 'area_pid' => 130400, 'area_name' => '邯山区', 'lng' => 114.484, 'lat' => 36.6001 ], [ 'area_id' => 130403, 'area_pid' => 130400,
'area_name' => '丛台区', 'lng' => 114.493, 'lat' => 36.6185 ], [ 'area_id' => 130404, 'area_pid' => 130400, 'area_name' => '复兴区', 'lng' =>
114.459, 'lat' => 36.6113 ], [ 'area_id' => 130406, 'area_pid' => 130400, 'area_name' => '峰峰矿区', 'lng' => 114.211, 'lat' => 36.4194 ], [
'area_id' => 130421, 'area_pid' => 130400, 'area_name' => '邯郸县', 'lng' => 114.531, 'lat' => 36.5938 ], [ 'area_id' => 130423, 'area_pid' =>
130400, 'area_name' => '临漳县', 'lng' => 114.619, 'lat' => 36.3346 ], [ 'area_id' => 130424, 'area_pid' => 130400, 'area_name' => '成安县',
'lng' => 114.67, 'lat' => 36.4441 ], [ 'area_id' => 130425, 'area_pid' => 130400, 'area_name' => '大名县', 'lng' => 115.154, 'lat' => 36.2799 ],
[ 'area_id' => 130426, 'area_pid' => 130400, 'area_name' => '涉县', 'lng' => 113.692, 'lat' => 36.5807 ], [ 'area_id' => 130427, 'area_pid' =>
130400, 'area_name' => '磁县', 'lng' => 114.374, 'lat' => 36.3739 ], [ 'area_id' => 130428, 'area_pid' => 130400, 'area_name' => '肥乡县', 'lng'
=> 114.8, 'lat' => 36.5481 ], [ 'area_id' => 130429, 'area_pid' => 130400, 'area_name' => '永年县', 'lng' => 114.489, 'lat' => 36.7836 ], [
'area_id' => 130430, 'area_pid' => 130400, 'area_name' => '邱县', 'lng' => 115.174, 'lat' => 36.8208 ], [ 'area_id' => 130431, 'area_pid' =>
130400, 'area_name' => '鸡泽县', 'lng' => 114.874, 'lat' => 36.9237 ], [ 'area_id' => 130432, 'area_pid' => 130400, 'area_name' => '广平县',
'lng' => 114.947, 'lat' => 36.4805 ], [ 'area_id' => 130433, 'area_pid' => 130400, 'area_name' => '馆陶县', 'lng' => 115.299, 'lat' => 36.5372
], [ 'area_id' => 130434, 'area_pid' => 130400, 'area_name' => '魏县', 'lng' => 114.935, 'lat' => 36.3617 ], [ 'area_id' => 130435, 'area_pid'
=> 130400, 'area_name' => '曲周县', 'lng' => 114.952, 'lat' => 36.7767 ], [ 'area_id' => 130481, 'area_pid' => 130400, 'area_name' => '武安市',
'lng' => 114.202, 'lat' => 36.6928 ] ] ], [ 'area_id' => 130500, 'area_pid' => 130000, 'area_name' => '邢台市', 'lng' => 114.509, 'lat' =>
37.0682, 'son' => [ [ 'area_id' => 130502, 'area_pid' => 130500, 'area_name' => '桥东区', 'lng' => 114.507, 'lat' => 37.068 ], [ 'area_id' =>
130503, 'area_pid' => 130500, 'area_name' => '桥西区', 'lng' => 114.468, 'lat' => 37.0598 ], [ 'area_id' => 130521, 'area_pid' => 130500,
'area_name' => '邢台县', 'lng' => 114.566, 'lat' => 37.0456 ], [ 'area_id' => 130522, 'area_pid' => 130500, 'area_name' => '临城县', 'lng' =>
114.504, 'lat' => 37.4398 ], [ 'area_id' => 130523, 'area_pid' => 130500, 'area_name' => '内丘县', 'lng' => 114.512, 'lat' => 37.2867 ], [
'area_id' => 130524, 'area_pid' => 130500, 'area_name' => '柏乡县', 'lng' => 114.693, 'lat' => 37.4824 ], [ 'area_id' => 130525, 'area_pid' =>
130500, 'area_name' => '隆尧县', 'lng' => 114.776, 'lat' => 37.3535 ], [ 'area_id' => 130526, 'area_pid' => 130500, 'area_name' => '任县', 'lng'
=> 114.684, 'lat' => 37.1258 ], [ 'area_id' => 130527, 'area_pid' => 130500, 'area_name' => '南和县', 'lng' => 114.684, 'lat' => 37.0049 ], [
'area_id' => 130528, 'area_pid' => 130500, 'area_name' => '宁晋县', 'lng' => 114.921, 'lat' => 37.617 ], [ 'area_id' => 130529, 'area_pid' =>
130500, 'area_name' => '巨鹿县', 'lng' => 115.035, 'lat' => 37.218 ], [ 'area_id' => 130530, 'area_pid' => 130500, 'area_name' => '新河县',
'lng' => 115.25, 'lat' => 37.5272 ], [ 'area_id' => 130531, 'area_pid' => 130500, 'area_name' => '广宗县', 'lng' => 115.143, 'lat' => 37.0746 ],
[ 'area_id' => 130532, 'area_pid' => 130500, 'area_name' => '平乡县', 'lng' => 115.03, 'lat' => 37.0632 ], [ 'area_id' => 130533, 'area_pid' =>
130500, 'area_name' => '威县', 'lng' => 115.264, 'lat' => 36.9768 ], [ 'area_id' => 130534, 'area_pid' => 130500, 'area_name' => '清河县', 'lng'
=> 115.665, 'lat' => 37.0712 ], [ 'area_id' => 130535, 'area_pid' => 130500, 'area_name' => '临西县', 'lng' => 115.501, 'lat' => 36.8708 ], [
'area_id' => 130581, 'area_pid' => 130500, 'area_name' => '南宫市', 'lng' => 115.391, 'lat' => 37.358 ], [ 'area_id' => 130582, 'area_pid' =>
130500, 'area_name' => '沙河市', 'lng' => 114.498, 'lat' => 36.8577 ] ] ], [ 'area_id' => 130600, 'area_pid' => 130000, 'area_name' => '保定市',
'lng' => 115.482, 'lat' => 38.8677, 'son' => [ [ 'area_id' => 130602, 'area_pid' => 130600, 'area_name' => '新市区', 'lng' => 115.459, 'lat' =>
38.8775 ], [ 'area_id' => 130603, 'area_pid' => 130600, 'area_name' => '北市区', 'lng' => 115.497, 'lat' => 38.8832 ], [ 'area_id' => 130604,
'area_pid' => 130600, 'area_name' => '南市区', 'lng' => 115.529, 'lat' => 38.8545 ], [ 'area_id' => 130621, 'area_pid' => 130600, 'area_name' =>
'满城县', 'lng' => 115.323, 'lat' => 38.9497 ], [ 'area_id' => 130622, 'area_pid' => 130600, 'area_name' => '清苑县', 'lng' => 115.493, 'lat' =>
38.7671 ], [ 'area_id' => 130623, 'area_pid' => 130600, 'area_name' => '涞水县', 'lng' => 115.715, 'lat' => 39.394 ], [ 'area_id' => 130624,
'area_pid' => 130600, 'area_name' => '阜平县', 'lng' => 114.197, 'lat' => 38.8476 ], [ 'area_id' => 130625, 'area_pid' => 130600, 'area_name' =>
'徐水县', 'lng' => 115.658, 'lat' => 39.021 ], [ 'area_id' => 130626, 'area_pid' => 130600, 'area_name' => '定兴县', 'lng' => 115.808, 'lat' =>
39.2631 ], [ 'area_id' => 130627, 'area_pid' => 130600, 'area_name' => '唐县', 'lng' => 114.985, 'lat' => 38.7451 ], [ 'area_id' => 130628,
'area_pid' => 130600, 'area_name' => '高阳县', 'lng' => 115.779, 'lat' => 38.7 ], [ 'area_id' => 130629, 'area_pid' => 130600, 'area_name' =>
'容城县', 'lng' => 115.872, 'lat' => 39.0535 ], [ 'area_id' => 130630, 'area_pid' => 130600, 'area_name' => '涞源县', 'lng' => 114.691, 'lat' =>
39.3539 ], [ 'area_id' => 130631, 'area_pid' => 130600, 'area_name' => '望都县', 'lng' => 115.157, 'lat' => 38.71 ], [ 'area_id' => 130632,
'area_pid' => 130600, 'area_name' => '安新县', 'lng' => 115.936, 'lat' => 38.9353 ], [ 'area_id' => 130633, 'area_pid' => 130600, 'area_name' =>
'易县', 'lng' => 115.498, 'lat' => 39.3489 ], [ 'area_id' => 130634, 'area_pid' => 130600, 'area_name' => '曲阳县', 'lng' => 114.701, 'lat' =>
38.6215 ], [ 'area_id' => 130635, 'area_pid' => 130600, 'area_name' => '蠡县', 'lng' => 115.577, 'lat' => 38.4897 ], [ 'area_id' => 130636,
'area_pid' => 130600, 'area_name' => '顺平县', 'lng' => 115.135, 'lat' => 38.8385 ], [ 'area_id' => 130637, 'area_pid' => 130600, 'area_name' =>
'博野县', 'lng' => 115.47, 'lat' => 38.4564 ], [ 'area_id' => 130638, 'area_pid' => 130600, 'area_name' => '雄县', 'lng' => 116.109, 'lat' =>
38.9944 ], [ 'area_id' => 130681, 'area_pid' => 130600, 'area_name' => '涿州市', 'lng' => 115.981, 'lat' => 39.4862 ], [ 'area_id' => 130682,
'area_pid' => 130600, 'area_name' => '定州市', 'lng' => 114.99, 'lat' => 38.5162 ], [ 'area_id' => 130683, 'area_pid' => 130600, 'area_name' =>
'安国市', 'lng' => 115.323, 'lat' => 38.4139 ], [ 'area_id' => 130684, 'area_pid' => 130600, 'area_name' => '高碑店市', 'lng' => 115.874, 'lat'
=> 39.3265 ] ] ], [ 'area_id' => 130700, 'area_pid' => 130000, 'area_name' => '张家口市', 'lng' => 114.884, 'lat' => 40.8119, 'son' => [ [
'area_id' => 130702, 'area_pid' => 130700, 'area_name' => '桥东区', 'lng' => 114.894, 'lat' => 40.7884 ], [ 'area_id' => 130703, 'area_pid' =>
130700, 'area_name' => '桥西区', 'lng' => 114.87, 'lat' => 40.8195 ], [ 'area_id' => 130705, 'area_pid' => 130700, 'area_name' => '宣化区',
'lng' => 115.065, 'lat' => 40.6096 ], [ 'area_id' => 130706, 'area_pid' => 130700, 'area_name' => '下花园区', 'lng' => 115.287, 'lat' => 40.5024
], [ 'area_id' => 130721, 'area_pid' => 130700, 'area_name' => '宣化县', 'lng' => 115.155, 'lat' => 40.5662 ], [ 'area_id' => 130722, 'area_pid'
=> 130700, 'area_name' => '张北县', 'lng' => 114.714, 'lat' => 41.1598 ], [ 'area_id' => 130723, 'area_pid' => 130700, 'area_name' => '康保县',
'lng' => 114.6, 'lat' => 41.8522 ], [ 'area_id' => 130724, 'area_pid' => 130700, 'area_name' => '沽源县', 'lng' => 115.689, 'lat' => 41.6696 ],
[ 'area_id' => 130725, 'area_pid' => 130700, 'area_name' => '尚义县', 'lng' => 113.971, 'lat' => 41.0778 ], [ 'area_id' => 130726, 'area_pid' =>
130700, 'area_name' => '蔚县', 'lng' => 114.589, 'lat' => 39.8407 ], [ 'area_id' => 130727, 'area_pid' => 130700, 'area_name' => '阳原县', 'lng'
=> 114.151, 'lat' => 40.1036 ], [ 'area_id' => 130728, 'area_pid' => 130700, 'area_name' => '怀安县', 'lng' => 114.386, 'lat' => 40.6743 ], [
'area_id' => 130729, 'area_pid' => 130700, 'area_name' => '万全县', 'lng' => 114.741, 'lat' => 40.7669 ], [ 'area_id' => 130730, 'area_pid' =>
130700, 'area_name' => '怀来县', 'lng' => 115.518, 'lat' => 40.4154 ], [ 'area_id' => 130731, 'area_pid' => 130700, 'area_name' => '涿鹿县',
'lng' => 115.224, 'lat' => 40.3764 ], [ 'area_id' => 130732, 'area_pid' => 130700, 'area_name' => '赤城县', 'lng' => 115.832, 'lat' => 40.9144
], [ 'area_id' => 130733, 'area_pid' => 130700, 'area_name' => '崇礼县', 'lng' => 115.28, 'lat' => 40.9752 ] ] ], [ 'area_id' => 130800,
'area_pid' => 130000, 'area_name' => '承德市', 'lng' => 117.939, 'lat' => 40.9762, 'son' => [ [ 'area_id' => 130802, 'area_pid' => 130800,
'area_name' => '双桥区', 'lng' => 117.943, 'lat' => 40.9747 ], [ 'area_id' => 130803, 'area_pid' => 130800, 'area_name' => '双滦区', 'lng' =>
117.745, 'lat' => 40.9538 ], [ 'area_id' => 130804, 'area_pid' => 130800, 'area_name' => '鹰手营子矿区', 'lng' => 117.66, 'lat' => 40.5474 ], [
'area_id' => 130821, 'area_pid' => 130800, 'area_name' => '承德县', 'lng' => 118.176, 'lat' => 40.7699 ], [ 'area_id' => 130822, 'area_pid' =>
130800, 'area_name' => '兴隆县', 'lng' => 117.501, 'lat' => 40.4171 ], [ 'area_id' => 130823, 'area_pid' => 130800, 'area_name' => '平泉县',
'lng' => 118.702, 'lat' => 41.0184 ], [ 'area_id' => 130824, 'area_pid' => 130800, 'area_name' => '滦平县', 'lng' => 117.333, 'lat' => 40.9415
], [ 'area_id' => 130825, 'area_pid' => 130800, 'area_name' => '隆化县', 'lng' => 117.73, 'lat' => 41.3141 ], [ 'area_id' => 130826, 'area_pid'
=> 130800, 'area_name' => '丰宁满族自治县', 'lng' => 116.649, 'lat' => 41.2048 ], [ 'area_id' => 130827, 'area_pid' => 130800, 'area_name' =>
'宽城满族自治县', 'lng' => 118.492, 'lat' => 40.6083 ], [ 'area_id' => 130828, 'area_pid' => 130800, 'area_name' => '围场满族蒙古族自治县',
'lng' => 117.76, 'lat' => 41.9437 ] ] ], [ 'area_id' => 130900, 'area_pid' => 130000, 'area_name' => '沧州市', 'lng' => 116.857, 'lat' =>
38.3106, 'son' => [ [ 'area_id' => 130902, 'area_pid' => 130900, 'area_name' => '新华区', 'lng' => 116.866, 'lat' => 38.3144 ], [ 'area_id' =>
130903, 'area_pid' => 130900, 'area_name' => '运河区', 'lng' => 116.857, 'lat' => 38.3135 ], [ 'area_id' => 130921, 'area_pid' => 130900,
'area_name' => '沧县', 'lng' => 116.878, 'lat' => 38.2936 ], [ 'area_id' => 130922, 'area_pid' => 130900, 'area_name' => '青县', 'lng' =>
116.803, 'lat' => 38.5835 ], [ 'area_id' => 130923, 'area_pid' => 130900, 'area_name' => '东光县', 'lng' => 116.537, 'lat' => 37.8857 ], [
'area_id' => 130924, 'area_pid' => 130900, 'area_name' => '海兴县', 'lng' => 117.498, 'lat' => 38.1396 ], [ 'area_id' => 130925, 'area_pid' =>
130900, 'area_name' => '盐山县', 'lng' => 117.231, 'lat' => 38.0565 ], [ 'area_id' => 130926, 'area_pid' => 130900, 'area_name' => '肃宁县',
'lng' => 115.83, 'lat' => 38.4227 ], [ 'area_id' => 130927, 'area_pid' => 130900, 'area_name' => '南皮县', 'lng' => 116.702, 'lat' => 38.0411 ],
[ 'area_id' => 130928, 'area_pid' => 130900, 'area_name' => '吴桥县', 'lng' => 116.385, 'lat' => 37.6255 ], [ 'area_id' => 130929, 'area_pid' =>
130900, 'area_name' => '献县', 'lng' => 116.127, 'lat' => 38.1923 ], [ 'area_id' => 130930, 'area_pid' => 130900, 'area_name' =>
'孟村回族自治县', 'lng' => 117.104, 'lat' => 38.0534 ], [ 'area_id' => 130981, 'area_pid' => 130900, 'area_name' => '泊头市', 'lng' => 116.578,
'lat' => 38.0836 ], [ 'area_id' => 130982, 'area_pid' => 130900, 'area_name' => '任丘市', 'lng' => 116.103, 'lat' => 38.7112 ], [ 'area_id' =>
130983, 'area_pid' => 130900, 'area_name' => '黄骅市', 'lng' => 117.339, 'lat' => 38.3706 ], [ 'area_id' => 130984, 'area_pid' => 130900,
'area_name' => '河间市', 'lng' => 116.099, 'lat' => 38.4455 ] ] ], [ 'area_id' => 131000, 'area_pid' => 130000, 'area_name' => '廊坊市', 'lng'
=> 116.714, 'lat' => 39.5292, 'son' => [ [ 'area_id' => 131002, 'area_pid' => 131000, 'area_name' => '安次区', 'lng' => 116.703, 'lat' =>
39.5206 ], [ 'area_id' => 131003, 'area_pid' => 131000, 'area_name' => '广阳区', 'lng' => 116.711, 'lat' => 39.5228 ], [ 'area_id' => 131022,
'area_pid' => 131000, 'area_name' => '固安县', 'lng' => 116.299, 'lat' => 39.4383 ], [ 'area_id' => 131023, 'area_pid' => 131000, 'area_name' =>
'永清县', 'lng' => 116.501, 'lat' => 39.3207 ], [ 'area_id' => 131024, 'area_pid' => 131000, 'area_name' => '香河县', 'lng' => 117.006, 'lat' =>
39.7613 ], [ 'area_id' => 131025, 'area_pid' => 131000, 'area_name' => '大城县', 'lng' => 116.654, 'lat' => 38.7053 ], [ 'area_id' => 131026,
'area_pid' => 131000, 'area_name' => '文安县', 'lng' => 116.458, 'lat' => 38.8732 ], [ 'area_id' => 131028, 'area_pid' => 131000, 'area_name' =>
'大厂回族自治县', 'lng' => 116.989, 'lat' => 39.8865 ], [ 'area_id' => 131081, 'area_pid' => 131000, 'area_name' => '霸州市', 'lng' => 116.392,
'lat' => 39.1257 ], [ 'area_id' => 131082, 'area_pid' => 131000, 'area_name' => '三河市', 'lng' => 117.072, 'lat' => 39.9836 ] ] ], [ 'area_id'
=> 131100, 'area_pid' => 130000, 'area_name' => '衡水市', 'lng' => 115.666, 'lat' => 37.7351, 'son' => [ [ 'area_id' => 131102, 'area_pid' =>
131100, 'area_name' => '桃城区', 'lng' => 115.675, 'lat' => 37.735, ], [ 'area_id' => 131121, 'area_pid' => 131100, 'area_name' => '枣强县',
'lng' => 115.726, 'lat' => 37.5103 ], [ 'area_id' => 131122, 'area_pid' => 131100, 'area_name' => '武邑县', 'lng' => 115.887, 'lat' => 37.8018
], [ 'area_id' => 131123, 'area_pid' => 131100, 'area_name' => '武强县', 'lng' => 115.982, 'lat' => 38.0414 ], [ 'area_id' => 131124, 'area_pid'
=> 131100, 'area_name' => '饶阳县', 'lng' => 115.726, 'lat' => 38.2353 ], [ 'area_id' => 131125, 'area_pid' => 131100, 'area_name' => '安平县',
'lng' => 115.519, 'lat' => 38.2339 ], [ 'area_id' => 131126, 'area_pid' => 131100, 'area_name' => '故城县', 'lng' => 115.971, 'lat' => 37.3477
], [ 'area_id' => 131127, 'area_pid' => 131100, 'area_name' => '景县', 'lng' => 116.269, 'lat' => 37.6926 ], [ 'area_id' => 131128, 'area_pid'
=> 131100, 'area_name' => '阜城县', 'lng' => 116.144, 'lat' => 37.8688 ], [ 'area_id' => 131181, 'area_pid' => 131100, 'area_name' => '冀州市',
'lng' => 115.579, 'lat' => 37.5508 ], [ 'area_id' => 131182, 'area_pid' => 131100, 'area_name' => '深州市', 'lng' => 115.56, 'lat' => 38.0011 ]
] ] ] ] ]; ?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
th,
td {
border: 1px solid;
}
table {
background-color: hotpink;
border-collapse: collapse;
}
</style>
<title>省市区信息表</title>
</head>
<body>
<div class="box">
<table class="province">
<caption>
省级信息表
</caption>
<thead>
<tr>
<th>省级行政区划代码</th>
<th>省名称</th>
<th>经度</th>
<th>纬度</th>
</tr>
</thead>
<tbody>
<?php
//一次遍历出第一级信息:省级信息
foreach ( $arr as $val ) {
// echo'<pre>'; // print_r( $val ); ?>
<tr>
<td><?php echo $val['area_id'] ?></td>
<td><?php echo $val['area_name'] ?></td>
<td><?php echo $val['lng'] ?></td>
<td><?php echo $val['lat'] ?></td>
</tr>
<?php }
?>
</tbody>
</table>
<table class="city">
<caption>
市级信息表
</caption>
<thead>
<tr>
<th>省级行政区划代码</th>
<th>省名称</th>
<th>市级行政区划代码</th>
<th>市名称</th>
<th>经度</th>
<th>纬度</th>
</tr>
</thead>
<tbody>
<?php
foreach ( $arr as $val ) {
// echo'<pre>'; print_r( $val["son"] );
//二次遍历出第二级信息:城市信息
foreach($val["son"] as $city){
// echo'<pre>';
// print_r($city);
?>
<tr>
<td><?php echo $val['area_id'] ?></td>
<td><?php echo $val['area_name'] ?></td>
<td><?php echo $city['area_id'] ?></td>
<td><?php echo $city['area_name'] ?></td>
<td><?php echo $city['lng'] ?></td>
<td><?php echo $city['lat'] ?></td>
</tr>
<?php }}
?>
</tbody>
</table>
<table class="county">
<caption>
区/县/地级市信息表
</caption>
<thead>
<tr>
<th>省级行政区划代码</th>
<th>省名称</th>
<th>市级行政区划代码</th>
<th>市名称</th>
<th>区/县/地级市级行政区划代码</th>
<th>区/县/地级市名称</th>
<th>经度</th>
<th>纬度</th>
</tr>
</thead>
<tbody>
<?php
foreach ( $arr as $val ) {
// echo'<pre>'; print_r( $val["son"] );
foreach($val["son"] as $city){
//三次遍历出第三级信息:区县信息
foreach($city["son"] as $county){
// echo'<pre>';
// print_r($county);
?>
<tr>
<td><?php echo $val['area_id'] ?></td>
<td><?php echo $val['area_name'] ?></td>
<td><?php echo $city['area_id'] ?></td>
<td><?php echo $city['area_name'] ?></td>
<td><?php echo $county['area_id'] ?></td>
<td><?php echo $county['area_name'] ?></td>
<td><?php echo $county['lng'] ?></td>
<td><?php echo $county['lat'] ?></td>
</tr>
<?php }}}
?>
</tbody>
</table>
</div>
</body>
</html>
最终实现效果: