Blogger Information
Blog 47
fans 0
comment 3
visits 44836
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
使用递归函数遍历省市区数组
江流
Original
998 people have browsed it

使用递归函数遍历省市区数组

数组保存在area.php文件中。

  1. include "area.php"; //导入文件
  2. //调用函数
  3. putout($arr);
  4. //声明递归函数
  5. function putout($arr){
  6. foreach($arr as $item){
  7. echo $item['area_name']." ";
  8. if(isset($item['son'])){
  9. echo "<br>";
  10. //递归调用函数
  11. putout($item['son']);
  12. echo "<br>";
  13. }
  14. if($item['area_pid']==0){
  15. echo "<hr>";
  16. }
  17. }
  18. }
  • 运行效果
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