次の配列があります。parentId
キー重要!
Array
(
[0] => Array
(
[id] => 1
[name] => Home
[parentId] =>
[children] =>
)
[1] => Array
(
[id] => 2
[name] => About
[parentId] =>
[children] =>
)
[2] => Array
(
[id] => 3
[name] => Services
[parentId] => 2
[children] =>
)
)
以下は私のexpected
配列の結果です。id isと servicesparentId Services
is の下に is is が表示されます。About
2
2
Array
(
[0] => Array
(
[id] => 1
[name] => Home
[parentId] =>
[children] =>
)
[1] => Array
(
[id] => 2
[name] => About
[parentId] =>
[children] => Array
(
[0] => Array
(
[id] => 3
[name] => Services
[parentId] => 2
[children] =>
)
)
)
)
array_walk
or array_map
and でforeach
簡単にできます。
function
SQL JOIN なしで配列インデックスを結合するものがあるのだろうforeach loop
か?
だから私の配列で:id = parentId