This article mainly introduces how php can be used to search for the genealogy tree by iteration in the breadcrumb navigation. it involves php iteration techniques and application methods and is of great practical value, for more information about how php can be used in the breadcrumb navigation, see the example in this article. Share it with you for your reference. The specific implementation method is as follows:
<? Phpecho""; $ Area = array ('id' => 1, 'region' => '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 District ', 'pid' => 1 ), array ('id' => 12, 'area '=> 'haidian District', 'pid '=> 1), array ('id' => 21, 'area '=> 'nanning city', 'pid '=> 2), array ('id' => 45, 'area' => 'Fuzhou city ', 'pid '=> 4), array ('id' => 113, 'area' => 'Asian games cune', '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 will help you with php programming.