I have a problem with my recursional function. May be you can help me.
My function below:

```
function showTree($items, $level = 0) {

            $arr = [];

            foreach ($items as $item) {
                $arr[] = str_repeat(":", $level * 2) . $item['name'] . "<br />";
                if (!empty($item['children'][0])) {
                    $level++;
                    $arr[] = $this->showTree($item['children'], $level);
                }
            }

            return $arr;
}

```

And this generate the output:

```
Array
(
    [0] => Category1

    [1] => Array
        (
            [0] => ::SubCategory2

            [1] => ::SubCategory1

            [2] => Array
                (
                    [0] => ::::SubSubCategory

                )

        )

)

```

But I need a little bit other data as my output:

```
 Array
    (
        [0] => Category1
        [1] => ::SubCategory2
        [2] => ::SubCategory1
        [3] => ::::SubSubCategory

    )

```

Where is my mistake? Thanks!

P>S:

Input:

```
Array
(
    [0] => Array
        (
            [id] => 1
            [name] => Category1
            [parent] => 0
            [children] => Array
                (
                    [0] => Array
                        (
                            [id] => 4
                            [name] => SubCategory2
                            [parent] => 1
                            [children] => Array
                                (
                                )

                        )

                    [1] => Array
                        (
                            [id] => 2
                            [name] => SubCategory1
                            [parent] => 1
                            [children] => Array
                                (
                                    [0] => Array
                                        (
                                            [id] => 3
                                            [name] => SubSubCategory
                                            [parent] => 2
                                            [children] => Array
                                                (
                                                )

                                        )

                                )

                        )

                )

        )
)

```