我有下面的$test
数组按“日期”和“网站”排序。
$test = array (
0 => array (
'id' => '45',
'rating' => 'p1',
'site' => 'Heavener SW',
'time' => '11-03-2012 Sat 10:00:00',
),
1 => array (
'id' => '45',
'rating' => 'h3',
'site' => 'Heavener SW',
'time' => '11-03-2012 Sat 10:00:00',
),
2 => array (
'id' => '45',
'rating' => 'h4',
'site' => 'Heavener SW',
'time' => '11-03-2012 Sat 16:00:00',
),
3 => array (
'id' => '110',
'rating' => 'p3',
'site' => 'Red Oak',
'time' => '11-03-2012 Sat 16:00:00',
),
4 => array (
'id' => '110',
'rating' => 'h3',
'site' => 'Red Oak',
'time' => '11-03-2012 Sat 16:00:00',
),
5 => array (
'id' => '32',
'rating' => 'p2',
'site' => 'Panopoint',
'time' => '11-04-2012 Sun 10:00:00',
)
);
我已经疯了,试图为每个“站点”-“时间”组合组合“评级”。
$result = array (
0 => array (
'id' => '45',
'rating' => 'p1, h3',
'site' => 'Heavener SW',
'time' => '11-03-2012 Sat 10:00:00',
),
2 => array (
'id' => '45',
'rating' => 'h4',
'site' => 'Heavener SW',
'time' => '11-03-2012 Sat 16:00:00',
),
3 => array (
'id' => '110',
'rating' => 'p3, h3',
'site' => 'Red Oak',
'time' => '11-03-2012 Sat 16:00:00',
),
5 => array (
'id' => '32',
'rating' => 'p2',
'site' => 'Panopoint',
'time' => '11-04-2012 Sun 10:00:00',
)
);
一个站点可以拥有的“评级”数量或有多少“站点”或“时间”没有限制(在合理范围内)。在 中保留索引$result
是可选的(即不是必需的)。
我发现了这个类似的帖子(和其他帖子),但我不明白如何实现。 根据价值获取所有相关的
我已经尝试了很多不同的方式,我的头在旋转,非常感谢任何帮助!