我有一个数组如下。
array(
0 => array(
'parent' => 'Bigboss',
'middle' => 'Technicians',
'child' => 'Players'
),
1 => array(
'parent' => 'Company',
'middle' => 'Manager',
'child' => 'Employees'
),
2 => array(
'parent' => 'Bigboss',
'middle' => 'Manager',
'child' => 'Workers'
),
3 => array(
'parent' => 'Company',
'middle' => 'Techinical Lead',
'child' => 'Employees'
),
4 => array(
'parent' => 'Bigboss',
'middle' => 'Workers',
'child' => 'Employees'
)
);
我希望这个数组以层次结构的方式像
parent
=> middle
=> child
parent
=> middle
=> child
就像下面这样。
array(
'Biggboss' => array(
'Technicians' => array(
0 => 'Players'
),
'Manager' => array(
0 => 'Workers'
),
'Workers' => array(
0 => 'Employees'
)
),
'Company' => array(
'Manager' => array(
0 => 'Employees'
),
'Techinical Lead' => array(
0 => 'Employees'
)
)
);
如果有人可以解决它,将不胜感激。