Skip to content

Latest commit

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Tree

Используется для преобразования списка (массива) элементов вида:

$categories = [
[
'cid' => 1,
'sub_id' => 0,
'name' => 'Category 1'
],
[
'cid' => 2,
'sub_id' => 0,
'name' => 'Category 2'
],
[
'cid' => 3,
'sub_id' => 1,
'name' => 'Category 3'
],
[
'cid' => 4,
'sub_id' => 3,
'name' => 'Category 4'
],
[
'cid' => 5,
'sub_id' => 3,
'name' => 'Category 5'
],
[
'cid' => 6,
'sub_id' => 2,
'name' => 'Category 6'
],
[
'cid' => 7,
'sub_id' => 5,
'name' => 'Category 7'
],
[
'cid' => 8,
'sub_id' => 7,
'name' => 'Category 8'
],
];

в древовидную структуру

[
[
'cid' => 1,
'sub_id' => 0,
'name' => 'Category 1',
'children' => [
[
'cid' => 3,
'sub_id' => 1,
'name' => 'Category 3',
'children' => [...]
],
...
],
...
]
]

что очень помогает выводить подобные струкутры:

Category 1
- Category 3
-- Category 4
-- Category 5
---- Category 7
---- Category 8
Category 2
- Category 6

см. примеры https://github.com/toolsparty/tree/tree/master/example

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages