I work with PHP. I have an array, made like this : (the level attribute is the level of the branch in the tree I want to make)
Array (
[0] => stdClass Object
(
[value] => Array
(
[name] => Dog
[level] => 1
)
)
[1] => stdClass Object
(
[value] => Array
(
[name] => Yorkshire
[level] => 2
)
)
[2] => stdClass Object
(
[value] => Array
(
[name] => Rottweiler
[level] => 2
)
)
[3] => stdClass Object
(
[value] => Array
(
[name] => Cat
[level] => 1
)
)
)
My goal is to make some kind of tree array from it, something like this :
Array (
[0] => stdClass Object
(
[value] => Array
(
[name] => Dog
[level] => 1
)
)
Array (
[1] => stdClass Object
(
[value] => Array
(
[name] => Yorkshire
[level] => 2
)
)
[2] => stdClass Object
(
[value] => Array
(
[name] => Rottweiler
[level] => 2
)
)
)
[3] => stdClass Object
(
[value] => Array
(
[name] => Cat
[level] => 1
)
)
)
But I really can't manage to do it. I even have issues to see the algorithm! Any help would be greatly appreciated.