Array types CODE
Indexed array
$colors = ["Red", "Green", "Blue"];
$colors[] = "Yellow";
Associative arrays
$student = [
	"name"=>"George", 
	"weight"=>77, 
	"height"=>1.8, 
	"male"=>true
];
$student["male"] = true;
echo 'George is ' . $student['weight'] . 'kg'."\n";
Multidimensional arrays
$students = [
	"George"=> [
		"name"=>"George", 
		"weight"=>77, 
		"height"=>1.8, 
		"male"=>true
	],
	"Alex"=> [
		"name"=>"Alex", 
		"weight"=>87, 
		"height"=>2.8, 
		"male"=>true,
		"parents"=> [
			"father"=>"David",
			"mother"=>"Marta",
		]
	],
	
];
echo 'Alex weighs ' . $students['Alex']['weight'] . 'kg'."\n";
echo "Alex's father is: " . $students['Alex']['parents']['father'];
by Valeri Tandilashvili
2 years ago
PHP
4
Pro tip: use ```triple backticks around text``` to write in code fences