Php can be applied to the iteration of breadcrumb navigation to find the Genealogy Tree.

Source: Internet
Author: User
This article mainly introduces how php can be applied to the iteration of the breadcrumb navigation to find the Genealogy Tree. It involves php iteration techniques and application methods, which are of great practical value. For more information, see

This article mainly introduces how php can be applied to the iteration of the breadcrumb navigation to find the Genealogy Tree. It involves php iteration techniques and application methods, which are of great practical value. For more information, see

The example in this article describes how php can be used to search for the Genealogy Tree by iteration In the breadcrumb navigation. 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.

,
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.