array("Maths"=>"0","Francais"=>"0","Anglais"=>"0","Histoire-Geographie"=>"0","Sport"=>"0") );现在我想在后"/> array("Maths"=>"0","Francais"=>"0","Anglais"=>"0","Histoire-Geographie"=>"0","Sport"=>"0") );现在我想在后">
Home > Backend Development > PHP Tutorial > PHP 二维数组追加赋值有关问题~

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

WBOY
Release: 2016-06-13 11:19:06
Original
911 people have browsed it

PHP 二维数组追加赋值问题~~~~~~~~~
我有一个学生名字和成绩的数组

<br />$etudiants=array("AAA"=>array("Maths"=>"0","Francais"=>"0","Anglais"=>"0","Histoire-Geographie"=>"0","Sport"=>"0")<br />	);<br />
Copy after login


现在我想在后面追加一个赋值
<br />"BBB"=>array("Maths"=>"1","Francais"=>"0","Anglais"=>"0","Histoire-Geographie"=>"0","Sport"=>"0")<br />
Copy after login


变成

$etudiants=array(
"AAA"=>array("Maths"=>"0","Francais"=>"0","Anglais"=>"0","Histoire-Geographie"=>"0","Sport"=>"0"),<br />"BBB"=>array("Maths"=>"1","Francais"=>"0","Anglais"=>"0","Histoire-Geographie"=>"0","Sport"=>"0")<br /> );
Copy after login


谢谢


------解决方案--------------------
<br />$etudiants["BBB"] = array("Maths"=>"1","Francais"=>"0","Anglais"=>"0","Histoire-Geographie"=>"0","Sport"=>"0");<br />
Copy after login

<br />$etudiants = array("AAA"=>array("Maths"=>"0","Francais"=>"0","Anglais"=>"0","Histoire-Geographie"=>"0","Sport"=>"0"));<br />$additional = array("BBB"=>array("Maths"=>"1","Francais"=>"0","Anglais"=>"0","Histoire-Geographie"=>"0","Sport"=>"0"));<br />$cards = array_merge($etudiants, $additional);  <br />print "<pre class="brush:php;toolbar:false">";<br />print_r($cards); <br />
Copy after login

更多参考
array_push/array_combine

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template