我的关系表如下所示:
`relationships` (`relationship_id`, `relationship_individual`, `parent_id`, `partner_id`) VALUES
(28, 160, 161, NULL),
(29, 161, 163, 162),
(30, 162, NULL, 161),
(31, 163, NULL, 164),
(32, 164, NULL, 163),
(34, 166, NULL, 165),
(36, 165, NULL, 166);
我想只显示一次合作伙伴。我试着这样做:
foreach($tree as $child) {
foreach($tree as $c) {
if($child['relationship_individual'] != $c['relationship_individual'] && $child['partner_id'] == $c['relationship_individual']){
unset($tree[$child['partner_id']]);
}
}
}
print_r($tree);
但它不起作用,什么也没有发生。我应该怎么办?