问答详情
源自:6-15 PHP中结构嵌套之循环嵌套

请问各位,如果对二维数组进行合并,数组键值进行运算?

<?php

 $students = array(

'2010'=>array('令狐冲',"59"),

'2011'=>array('林平之',"44"),

'2012'=>array('曲洋',"89"),

'2013'=>array('任盈盈',"92"),

'2014'=>array('向问天',"93"),

'2015'=>array('任我行',"87"),

'2016'=>array('冲虚',"58"),

'2017'=>array('方正',"74"),

'2018'=>array('岳不群',"91"),

'2019'=>array('宁中则',"90"),

'2020'=>array('宁中则',"80"),

);

?>

这个二维数组中,把 “宁中则”合并,合并后的效果为:

<?php

 $students = array(

'2010'=>array('令狐冲',"59"),

'2011'=>array('林平之',"44"),

'2012'=>array('曲洋',"89"),

'2013'=>array('任盈盈',"92"),

'2014'=>array('向问天',"93"),

'2015'=>array('任我行',"87"),

'2016'=>array('冲虚',"58"),

'2017'=>array('方正',"74"),

'2018'=>array('岳不群',"91"),

'2019'=>array('宁中则',"170");

?>


提问者:qq_真诚_7 2018-08-28 11:00

个回答