3
我有点混淆了如何基于共同的价值重新组合数组。这里是下面的数组:php多维数组分组
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
)
)
,我想这组由它的团队价值像下面这样:
Array ( [1] => 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 ) ) [2] => Array ( [0] => Array( [team] => 1 [id] => 8 [user] =>consultant3 [Designation] => Consultant ) [1] => Array( [team] => 1 [id] => 9 [user] =>teamleader2 [Designation] => Team Leader ) ) )
两个主要的阵列组是球队本身。任何想法/帮助将不胜感激。提前致谢!
问候
不需要检查与isset,PHP创建它适合你,如果不存在的话。 – hakre
这个尖叫声。但是PHP5.3实际上并没有提出一个。不知道... - 虽然看起来很奇怪。 – rodneyrehm
这不会给出通知,请参阅http://codepad.org/VdoMnfTD,PHP 5.2:http://ideone.com/vPTKw – hakre