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); now I want to append the value assignment problem to the PHP two-dimensional array ~~~~~~~~~
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