言語 => タイプ => 製品 => などの 1 対 1 の線形ツリーがあります。言語には多くの型があり、型には多くの製品があります。
次のスタイルで配列を返す再帰関数を作成しました。
Array
(
[0] => Array
(
[id] => 166
[name] => product1
[type] => product
[depth] => 2
[parent] => Array
(
[0] => Array
(
[id] => 165
[name] => default
[type] => type
[depth] => 1
[parent] => Array
(
[0] => Array
(
[id] => 1
[name] => en
[type] => language
[depth] => 0
[parent] => false
)
)
)
)
)
)
私が欲しいのは、そのツリーをトラバースし、次のような配列を提供する再帰メソッドです。
[0] => array( 'id' => 1, 'name' => 'en'),
[1] => array( 'id' => 165, 'name' => 'default'),
[2] => array( 'id' => 166, 'name' => 'product1')
0,1,2 がその要素に等しいdepth
ので、データのブレッドクラムを作成できます。
ありがとうございました。