Question about append assignment of two-dimensional arrays in PHP ~~~~~~~~~ I have an array of student names and scores $ etudiantsarray (AAA & gt; array (Maths & gt; 0, Francais & gt; 0, Anglais & gt; 0, histoire-Geographie & gt; 0, Sport & gt; 0); PHP two-dimensional array appending assignment ~~~~~~~~~
I have an array of student names and scores.
$etudiants=array("AAA"=>array("Maths"=>"0","Francais"=>"0","Anglais"=>"0","Histoire-Geographie"=>"0","Sport"=>"0")
);
Now I want to append a value to the end.
"BBB"=>array("Maths"=>"1","Francais"=>"0","Anglais"=>"0","Histoire-Geographie"=>"0","Sport"=>"0")
Change
$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")
);
Thank you.
------ Solution --------------------
$etudiants["BBB"] = array("Maths"=>"1","Francais"=>"0","Anglais"=>"0","Histoire-Geographie"=>"0","Sport"=>"0");
Or
$ 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);
More references
Array_push/array_combine