Blogger Information
Blog 40
fans 0
comment 0
visits 27855
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
foreach 获取省市区
初见
Original
395 people have browsed it

遍历省市区

print_r 打印

  1. print_r($arr);//数组中所有元素
  2. print_r($arr[0]); //数组中第一项
  3. print_r($arr[0]['son'][0]['son']);//打印北京市下所有区

echo 输出单个值

  1. echo $arr[1]['area_name'];//打印第二个名称

foreach 循环

  1. foreach ($arr as $sheng){
  2. echo '| - '.$sheng['area_id'].'-'.$sheng['area_name'].'-'.$sheng['lng'].'-'.$sheng['lat'].'<br />';
  3. foreach ($sheng['son'] as $shi){
  4. echo '| - | - '.$shi['area_id'].'-'.$shi['area_pid'].'-'.$shi['area_name'].'-'.$shi['lng'].'-'.$shi['lat'].'<br />';
  5. foreach ($shi['son'] as $qu){
  6. echo '| - | - | - '.$qu['area_id'].'-'.$qu['area_pid'].'-'.$qu['area_name'].'-'.$qu['lng'].'-'.$qu['lat'].'<br />';
  7. }
  8. }
  9. }
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