Blogger Information
Blog 9
fans 0
comment 0
visits 7014
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
1. 循环省市区 2. print_f打印其中一个城市和区
choa fan
Original
575 people have browsed it

1、循环省市区

foreach($arr as $k1=> $v1) {    echo '省份名: '.$v1['area_name'].', id是: '.$v1['area_id'].', 精度: '.$v1['lng'].', 维度: '.$v1['lat'];    echo '<hr/>';    foreach($v1['son'] as $k2 => $v2) {        echo '----城市名: '.$v2['area_name'].', id是: '.$v2['area_id'].', 精度: '.$v2['lng'].', 维度: ',$v2['lat'];        echo '<hr/>';        foreach ($v2['son'] as $k3 => $v3) {            echo '--------区域名: '.$v3['area_name'].', id是: '.$v3['area_id'].', 精度: '.$v3['lng'].', 维度: ',$v3['lat'];            echo '<br/>';        }    }}

2、print_f打印其中一个城市和区

echo $arr[2]['area_name']; //河北省echo '<hr/>';echo $arr[2]['son'][0]['area_name']; // 石家庄市echo '<hr/>';echo $arr[2]['son'][0]['son'][0]['area_name']; // 长安区echo '<hr/>';echo print_r($arr[2]['son']); // 所有市和区域echo '<hr/>';echo print_r($arr[2]['son'][0]['son']); // 所有区域
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