我有点困惑如何根据一个共同的值重新组合数组。以下是下面的数组:
Array
(
[0] => Array
(
[team] => 1
[id] => 5
[user] => teamleader1
[Designation] => Team Leader
)
[1] => Array
(
[team] => 1
[id] => 6
[user] => consultant1
[Designation] => Consultant
)
[2] => Array
(
[team] => 1
[id] => 7
[user] => consultant2
[Designation] => Consultant
)
[3] => Array
(
[team] => 2
[id] => 8
[user] => consultant3
[Designation] => Consultant
)
[4] => Array
(
[team] => 2
[id] => 9
[user] => teamleader2
[Designation] => Team Leader
)
)
我想按照其团队值对它进行分组,就像下面这样:
数组 ( [1] => 数组 ( [0] => 数组( [team] => 1 [id] => 5 [user] =>teamleader1 [Designation] => 团队领袖 ) [1] => 数组( [team] => 1 [id] => 6 [user] =>consultant1 [Designation] => 咨询师 ) [2] => 数组( [team] => 1 [id] => 7 [user] =>consultant2 [Designation] => 咨询师 ) ) [2] => 数组 ( [0] => 数组( [team] => 1 [id] => 8 [user] =>consultant3 [Designation] => 咨询师 ) [1] => 数组( [team] => 1 [id] => 9 [user] =>teamleader2 [Designation] => 团队领袖 ) ) )两个主要的数组组是各自的团队。任何想法/帮助都将不胜感激。谢谢!