We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 10d9ff4 commit 4425fd5Copy full SHA for 4425fd5
src/ListToTree.php
@@ -36,15 +36,12 @@ public function toTree()
36
$data = $this->list;
37
foreach ($data as $d) {
38
$items[$d[$this->node_index]] = $d;
39
- if (!isset($d[$this->parent_index]) || !isset($d[$this->node_index]) || isset($d[$this->node_name])) {
40
- return false;
41
- }
42
}
43
$tree = [];
44
$n = 0;
45
- foreach ($items as $item) {
+ foreach ($items as $node_index => $item) {
46
if (isset($items[$item[$this->parent_index]])) {
47
- $items[$item[$this->parent_index]][$this->node_name][] = &$items[$item[$this->node_index]];
+ $items[$item[$this->parent_index]][$this->node_name][] = &$items[$node_index];
48
} else {
49
$tree[$n++] = &$items[$item[$this->node_index]];
50
0 commit comments