Home >Backend Development >PHP Tutorial >PHP can be applied to the implementation method of recursively searching for family trees in breadcrumb navigation, applied to family trees_PHP tutorial

PHP can be applied to the implementation method of recursively searching for family trees in breadcrumb navigation, applied to family trees_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:08:261036browse

PHP can be applied to the recursive search for family tree tree implementation method of breadcrumb navigation, applied to family tree

The example in this article describes the implementation method of recursively searching for family tree trees that can be applied to breadcrumb navigation in PHP. Share it with everyone for your reference. The specific implementation method is as follows:

<&#63;php
echo "<pre class="brush:php;toolbar:false">";
$area = array(
array('id'=>1,'area'=>'北京','pid'=>0),
array('id'=>2,'area'=>'广西','pid'=>0),
array('id'=>3,'area'=>'广东','pid'=>0),
array('id'=>4,'area'=>'福建','pid'=>0),
array('id'=>11,'area'=>'朝阳区','pid'=>1),
array('id'=>12,'area'=>'海淀区','pid'=>1),
array('id'=>21,'area'=>'南宁市','pid'=>2),
array('id'=>45,'area'=>'福州市','pid'=>4),
array('id'=>113,'area'=>'亚运村','pid'=>11),
array('id'=>115,'area'=>'奥运村','pid'=>11),
array('id'=>234,'area'=>'武鸣县','pid'=>21)
); 

function familytree($arr,$id){
 static $list = array();
 foreach($arr as $v){
 if($v['id']==$id){
  familytree($arr,$v['pid']);
  $list[] = $v;
 }
 }
 return $list;
}
print_r(familytree($list,113));
&#63;>

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/951639.htmlTechArticlephp can be applied to the implementation method of recursively searching for family tree trees in breadcrumb navigation. When applied to family trees, this article illustrates how php can be used Implementation method for recursively searching family trees applied to breadcrumb navigation. Share to...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn