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

来源:6-15 PHP中结构嵌套之循环嵌套

qq_真诚_7

2018-08-28 11:00

<?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");

?>


写回答 关注

3回答

PHP入门篇

PHP入门教程轻松学习,行业大牛帮您快速掌握PHP编程基础知识。

455995 学习 · 6306 问题

查看课程

相似问题