0
我有一個數組,看起來像:試圖使孩子數組下父母陣列出現重組的陣列
$someArray = array(
array(
"id"=> 1,
"name"=> "somename1",
"parent"=> 0
),
array(
"id"=> 53,
"name"=> "somename2",
"parent"=> 1
),
array(
"id"=> 921,
"name"=> "somename3",
"parent"=> 53,
)
.
.
.
.
.
.
);
離岸金融中心有更多的細胞在陣列中,這只是一小部分
我我試圖把這個數組變成類似的東西:
$someArray = array(
array(
"id"=> 1,
"name"=> "somename1",
"parent"=> 0,
"children" => array(
array(
"id"=> 53,
"name"=> "somename2",
"parent"=> 1,
"children" => array(
array(
"id"=> 921,
"name"=> "somename3",
"parent"=> 53,
"children" => array(
)
)
)
)
)
)
.
.
.
.
.
.
);
我試了一天半,似乎無法完成它。
謝謝先進。