Tree-shaped structure to find subordinates

Source: Internet
Author: User

The existing tree structure is given below if cat_id 9 how to investigate 9 of all superiors and all subordinates

<?php array  (1 =>array  (           ' cat_id '  =>  ' 1 ',           ' cat_name '  =>   ' phone type ',           ' parent_id '  =>  ' 0 ',            ' child '  =>array  (             2 => array  (                ' cat_id '  =>  ' 2 ',                ' cat_name '  =>  ' CDMA phone ',                ' parent_id '  =>  ' 1 ',             ),             3 => array  (                ' cat_id '  =>  ' 3 ',                ' cat_name '  =>  ' GSM phone ',                ' parent_id '  =>  ' 1 ',             ),             4  => array  (                ' cat_id '  =>  ' 4 ',                ' cat_name '  =>  ' 3G mobile phone ',                ' parent_id '  =>  ' 1 ',             ),             5 => array  (                ' cat_id '  =>  ' 5 ',                ' cat_name '  =>  ' dual-mode phone ',                ' parent_id '  =>   ' 1 ',            ),           ),        ),   6 = > array  (           ' cat_id '  =>  ' 6 ' ,           ' cat_name '  =>  ' phone accessories ',            ' parent_id '  =>  ' 0 ',            'Child '  => array  (            7  => array  (   ' cat_id '  =>  ' 7 ',   ' cat_name '  =>  ' Charger ',   ' parent_id '  =>  ' 6 ',),             8 => array  (   ' cat_id '  =>  ' 8 ',   ' Cat_name '  =>  ' headphones ',   ' parent_id '  =>  ' 6 ',),             9 => array  (                ' cat_id '  =>  ' 9 ',                ' cat_name '  =>  ' battery ',                ' parent_id '  =>  ' 6 ',                   ' child '  => array (101=>array  (    ' cat_id '  =>  ' 101 ',   ' cat_name '  =>  ' Charger 101 ',   ' parent_id '  =>  ' 9 ',),102=>array  (   ' cat_id '  =>  ' 102 ',   ' cat_name '  =>  ' Charger 102 ',   ' parent_id '  =>  ' 9 ',),103=>array  (   ' Cat_ Id '  =>  ' 103 ',   ' cat_name '  =>  ' Charger 103 ',   ' parent_id '  =>   ' 9 ',), ),            ),             11 => array  (                ' cat_id '  =>  ' one ',                ' cat_name '  =>  ' card reader and memory cards ',                ' parent_id '  =>  ' 6 ',             ),           ),  12 => array  (,        ) (      ' cat_id '  =>  ',     ' cat_name '  =>  ' recharge card ',      ' parent_id '  =>  ' 0 ',     ' child '  =>   array  (  13 => array  ' cat_id '  =>  ', ' Cat_name '  =>   ' PHS/Landline Prepaid card ', ' parent_id '  =>  ',   ',  14 => array  (' cat_id '  =>  ', ' cat_name '  =>  ' mobile phone recharge card ', ' parent_id '  =>  ',  '  ),  15 => array  (' cat_id '  =>  ', ' cat_name '  =>  ' Unicom Mobile Prepaid card ', ' parent_id ' &NBSP;=&GT;&NBSP; ' (,  ),    ),  );


Tree-shaped structure to find subordinates

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.