This document discusses the different types of arrays in PHP. There are three main types: numeric arrays which use numeric indices, associative arrays where each key is associated with a value, and multi-dimensional arrays which contain one or more nested arrays. Examples are provided for each type to demonstrate how to define and access array elements.
2. What is Array ?
Array is used to store multiple values in a single
variable. It helps reducing the number of
variables in the code. In PHP we use 3 type array.
3. Types of Array
1. Numeric Array
2. Associative Array
3. Multi Dimensional Array
5. Associative Array
An array where each key is associated with a value.
$student = array("xyz"=>"9/8=>123,"abc"=>"3/12","zzz"=>"3/10");
foreach($student as $x=>$y=>$z)
{
echo "$x is $y is $z<br>";
}
6. Multi Dimensional Array
An array contain one or more array.
$student=array("punjab"=>array("jalandhar","phagwara","ludhiana"),
"haryana" => array("ambala","hisar"));
echo $student["punjab"][0];