PHP implementation recursive and Infinite classification method, PHP implementation recursive classification _php tutorial

Source: Internet
Author: User

PHP implementation recursive and Infinite classification method, PHP implementation of recursive classification


In this paper, we describe the recursive and infinite classification method of PHP, and share it 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 T ($arr, $pid =0, $lev =0) {Static $list = Array (), foreach ($arr as $v) {if ($v [' pid ']== $pid) {  echo str_repeat (" c1/> ", $lev). $v [' area ']."
"; The output here is to see the effect $list [] = $v; T ($arr, $v [' id '], $lev + 1); } } return $list;} $list = t ($area); echo " ";p Rint_r ($list);? >

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/959117.html www.bkjia.com true http://www.bkjia.com/PHPjc/959117.html techarticle PHP Implementation of recursive and infinite classification method, PHP implementation of recursive classification in this paper, the implementation of PHP recursive and Infinite classification method, share for everyone for reference. The concrete implementation method is as follows ...

  • 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.