After reading the unlimited classification of moderators and dividing them into tree structures, how can we restore them?

Source: Internet
Author: User
After reading the unlimited category of the moderator and dividing it into a tree structure, how can I restore the original array of the unlimited category of the parent and child ;? * Obtain the wireless category and arrange the node paths of the wireless category * $ aarray & nbsp; (& nbsp; 0 & nbsp; & gt; & nbsp; array & nbsp; (& nbsp; id & nbsp; & gt; & nbsp; 134, & nb read the unlimited category of the moderator, how to restore a tree structure

Unlimited parent-child category

Original array
/*
Obtain the wireless classification and arrange the node paths of the wireless classification.
*/
$ A = array (
0 =>
Array (
'Id' => '123 ',
'Fid' => '0 ',
'Name' => 'T ',
),
1 =>
Array (
'Id' => '123 ',
'Fid' => '0 ',
'Name' => 'K ',
),
2 =>
Array (
'Id' => '123 ',
'Fid' => '0 ',
'Name' => 'J ',
),
3 =>
Array (
'Id' => '123 ',
'Fid' => '123 ',
'Name' => 'I am k's classification 1 ',
),
4 =>
Array (
'Id' => '123 ',
'Fid' => '123 ',
'Name' => 'I Am t's classification t2 ',
),
5 =>
Array (
'Id' => '123 ',
'Fid' => '123 ',
'Name' => 'My name is t's classification T1 ',
),
6 =>
Array (
'Id' => '123 ',
'Fid' => '123 ',
'Name' => 'I am k classification 1-1 ',
),
7 =>
Array (
'Id' => '123 ',
'Fid' => '123 ',
'Name' => 'I am a k classification 1-1-1 ',
),
8 =>
Array (
'Id' => '123 ',
'Fid' => '123 ',
'Name' => 'I am a k classification 1-1-1-1 ',
),
)
?>

Start to form a tree and add a path. the tree array is $ trees.
Array
(
[0] => Array
(
[Id] = & gt; 134
[Fid] => 0
[Name] => t
[Path] = & gt; 134
[_ Sub] => Array
(
[0] => Array
(
[Id] = & gt; 136
[Fid] = & gt; 134
[Name] => I am a t2-class T2.
[Path] = & gt; 134,136
)

[1] => Array
(
[Id] = & gt; 135
[Fid] = & gt; 134
[Name] => I am a T'S class t1
[Path] = & gt; 134,135
)

)

)

[1] => Array
(

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.