PHP supports three types of arrays :
An indexed array stores values in sequential numeric indices, start from 0 . you can create an indexed array using the array() function or the [] shorthand syntax.
$country = array("India","USA","UK","UAE");
You can access the elements of an indexed array using their index :
echo $country[0]; // output “Indiaâ€
echo $country[1]; // output “USAâ€
An associative array stores values in Key-value pairs, where each key is a unique string identifier. you can create a n associative array using the array() function or the [] shorthand syntax.
$people=["name"=>"Manan","age"=>"25","mobile"=>"9878357855","email"=>"abc@domain.com"];
You can access the elements of an associative array using their key :
echo $people["name"]; // outputs is “Mananâ€
A multidimensional array is an array of arrays, where each element can be an indexed or associative array. You can create a multidimensional array using nested array.
$men = [
["name"=>"Pawan", “ageâ€=>20],
["name"=>"Manan", “ageâ€=>30],
["name"=>"Kuldeep", “ageâ€=>40]
];
you can access the elements of a multidimensional array using multiple indices:
echo $men[0]["name"]; // output is Pawan