我在这里查看了一些答案,但似乎没有使用这种方法?
我有一个项目数组,这些项目是对象。该对象可以有一个键,它是“孩子”,“孩子”是一个对象数组等。
有没有办法做到这一点?
例子:
Array
(
[1] => stdClass Object
(
[id] => 1
[name] => Steve King
[image] => upload/shop/fe7a66254e4249af2b0093efca75a914.jpg
[parent] => 0
[children] => Array
(
)
)
[2] => stdClass Object
(
[id] => 2
[name] => Eden Hall
[image] => upload/shop/064f60a98deba612e437ac549f1dc05d.jpg
[parent] => 0
[children] =>Array
(
[1] => stdClass Object
(
[id] => 1
[name] => Steve King
[image] => upload/shop/fe7a66254e4249af2b0093efca75a914.jpg
[parent] => 0
[children] => Array
(
)
)
)
[3] => stdClass Object
(
[id] => 3
[name] => Paula Johnson
[image] => upload/shop/1492a323090afbad07c35cf93fe6bdda.jpg
[parent] => 0
[children] => Array
(
)
)
[4] => stdClass Object
(
[id] => 4
[name] => Ethan Watson
[image] => upload/shop/677c720333af33bc58d0684d79918e03.jpg
[parent] => 0
[children] => Array
(
)
)
[5] => stdClass Object
(
[id] => 5
[name] => Abigail Adams
[image] => upload/shop/da1734277322fc3b2e84a9ddbcc2e2f1.jpg
[parent] => 0
[children] => Array
(
)
)