我有一个学生名字和成绩的数组
$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
哈哈谢谢了,
array_push/array_combine 这两个我试过了,效果不一样。
谢谢你的函数~~~~~~~~~~~~~~~