您好,欢迎访问一九零五行业门户网

PHP 二维数组追加赋值有关问题~

php 二维数组追加赋值问题~~~~~~~~~
我有一个学生名字和成绩的数组
$etudiants=array(aaa=>array(maths=>0,francais=>0,anglais=>0,histoire-geographie=>0,sport=>0)
);

现在我想在后面追加一个赋值
bbb=>array(maths=>1,francais=>0,anglais=>0,histoire-geographie=>0,sport=>0)

变成
$etudiants=array(
aaa=>array(maths=>0,francais=>0,anglais=>0,histoire-geographie=>0,sport=>0),
bbb=>array(maths=>1,francais=>0,anglais=>0,histoire-geographie=>0,sport=>0)
);

谢谢
------解决方案--------------------
$etudiants[bbb] = array(maths=>1,francais=>0,anglais=>0,histoire-geographie=>0,sport=>0);


$etudiants = array(aaa=>array(maths=>0,francais=>0,anglais=>0,histoire-geographie=>0,sport=>0));
$additional = array(bbb=>array(maths=>1,francais=>0,anglais=>0,histoire-geographie=>0,sport=>0));
$cards = array_merge($etudiants, $additional);
print ;
print_r($cards);

更多参考
array_push/array_combine
其它类似信息

推荐信息