PHP计算二维数组中一维数组相同键名的,键值相加

如以下数组中,另外一维数组是动态的$test=array(0=>array('AblestSong'=>0.36),1=>array('AlennKe'=>0.46),2... 如以下数组中,另外一维数组是动态的
$test=array(
0 => array('Ablest Song' => 0.36),
1 => array ('Alenn Ke' => 0.46),
2 => array( 'Andy T Gu' => 1.31),
3 => array ( 'Candy Tian' => 0.26),
4 => array ('Candy Tian' => 4.93),
5 => array ('Chun Liu' => 1.08),
6 => array ('Earlene Yin' => 5.33),
7 => array ('Guoquan Nie' => 0.08),
8 => array ('Guoquan Nie' => 0.2),
9 => array ('Hillwon Deng' => 0.5),
10 =>array ('Hillwon Deng' => 0.15),
11 =>array ('Honghao shen' => 1.01),
12 => array ('Huaiyu Li' => 0.3),
13 =>array ('Huaiyu Li' => 0.42),
14 =>array ('Ivy WX Chen' => 0.51),
15 => array('Ivy WX Chen' => 0.15),
16 =>array ('Jack J OU' => 0.88),
17 => array ('James W Wei' => 0.38),
18 => array ('Javen Tang' => 0.74),
19 =>array ('Javen Tang' => 0.74),
20 => array ('Kagaya Liao' => 0.22),
21 => array ('Kagaya Liao' => 0.46),
22 =>array('Lily H He' => 1.18),
23 => array('Luckly Wu' => 1.07),
24 =>array ('Manni Huang' => 0.26),
25 => array ('Manni Huang' => 0.23),
26 => array ('Mark Shen' => 0.74),
27 =>array('Mark Shen' => 0.03),
28 =>array('May Zhou' => 0.44),
29 =>array('May Zhou' => 0.44),
30 =>array('May Zhou' => 0.22),
31 =>array('May Zhou' => 0.22),
32 =>array('May Zhou' => 0.51),

33 =>array('Samuel JT Lin' => 0.29),
34 =>array('Samuel JT Lin' => 0.29),
35 =>array('Tariku Deng' => 1.07),
36 =>array('Tariku Deng' => 0.63),
37 =>array('Teddy Wu' => 0.49),
38 =>array('Teddy Wu' => 5.71),
39 => array('TingTing TT Zhang' => 0.98),
40 => array ('TingTing TT Zhang' => 0.73),
41 =>array('Wade Wu' => 0.69),
42 =>array('Wade Wu' => 0.28),
43 =>array('Willian Chen' => 0.95),
44 => array('Yuler Lee' => 0.68),
);
展开
 我来答
莫路草根
2018-11-02 · TA获得超过4102个赞
知道大有可为答主
回答量:4184
采纳率:85%
帮助的人:1012万
展开全部
$arr = array();
foreach($test as $v){
    if(isset($arr[key($v)])){
        $arr[key($v)] += current($v);
    }else{
        $arr[key($v)] = current($v);
    }
}
print_r($arr);

结果如图:

本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式