PHP can be applied to the iteration of breadcrumb navigation to find a family tree implementation method applied to genealogy
This paper presents an iterative approach to finding a family tree that PHP can apply to breadcrumb navigation. Share to everyone for your reference. The implementation method is as follows:
<?phpecho ""; $area = array (' ID ' =>1, ' area ' = ' Beijing ', ' pid ' =>0), array (' ID ' =>2, ' area ' = ' Guangxi ', ' pid ' =>0), Array (' ID ' =>3, ' area ' = ' Guangdong ', ' pid ' =>0), array (' ID ' =>4, ' area ' = ' Fujian ', ' pid ' =>0), array (' ID ' =>11, ' Area ' = ' Chaoyang ', ' pid ' =>1 ', array (' ID ' =>12, ' area ' = ' Haidian ', ' pid ' =>1), array (' ID ' =>21, ' area ' = ') Nanning ', ' pid ' =>2), array (' ID ' =>45, ' area ' + ' Fuzhou ', ' pid ' =>4), array (' ID ' =>113, ' area ' = ' Asian Games Village ', ' pid ' = >11), array (' ID ' =>115, ' area ' = ' Olympic Village ', ' pid ' =>11), array (' ID ' =>234, ' area ' = ' wuming county ', ' pid ' =>21 '); function Familytree ($arr, $id) {$list = Array (), while ($id) {$flag = false; foreach ($arr as $v) { if ($v [' id ']== $id) {
array_unshift ($list, $v [' area ']; $id = $v [' pid ']; $flag = true; } } if (! $flag) {break ;}} return $list;} Print_r (Familytree ($area, 113));? >
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/951633.html www.bkjia.com true http://www.bkjia.com/PHPjc/951633.html techarticle PHP can be applied to the iterative search for breadcrumb navigation to find a family tree implementation method, which is applied to the genealogy This paper describes the iterative search for the family tree implementation method that PHP can apply to breadcrumb navigation. Share to ...