A little Theory:
An array is a matrix / vector / array that stores values in 3 possible ways depending on its type.
- Numeric array
- Associative Array
- Multidimensional array
Numeric array
It is a type of array that has numerical indexes and is accessed with a whole number to each value of it.
example:
$numeric_array = array($value1, $value2, $value3,...);
a complete example:
$name = "Aner";
$numeric_array = array(1, 2, 3, "home", $name);
//get the length of array
$length = count($numeric_array);
//for cycle
for($i=0; $i<$length; $i++)
{
//get value of each element's array
echo $numeric_array[$i];
echo "<br>";
}
other method for acces to values is by index example:
$numeric_array[0];//this get the first element
Associative Array this is an array whose values are assigned by keys:
$assoc_array = array(key1=>value1, key2=>value2, key3=>value3...);
example:
$equipe = array(goalie=>'Cech', defending=>'Terry', medium=>'Lampard', Forward=>'Torres');
foreach($equipe as $position=>$player)
{
echo "the " . $position . " is " . $player;
echo "<br>";
}
othe method for access is by the key:
$equipe['goalie']
Multidimensional array A multidimensional array is an array containing one or more arrays.
PHP understands multidimensional arrays that are two, three, four, five, or more levels deep. However, arrays more than three levels deep are hard to manage for most people.
The dimension of an array indicates the number of indices you need to select an element.
Two-dimensional Arrays example:
echo "3-dimensional array:<br>";
$product=array(
array(
array("Epson Printer L110",100,4500),
array("Canon Printer",100,5000),
array("HP Laptop",500,40000)
),
array(
array("Micromax Canvas Lite",200,9000),
array("Samsung Galaxy",300,15000),
array("LAVA",100,4000)
),
array(
array("Sandisk 16 GB Pendrive",500,500),
array("Card Reader",500,50),
array("UPS",200,3000)
)
);
// accessing elements from 3-dimensional product array.
echo "<table border=1 cellpadding=5 cellspacing=5>";
echo "<tr>";
echo "<th>Product</th>";
echo "<th>Quantity</th>";
echo "<th>Price</th>";
echo "</tr>";
for($l=0;$l<3;$l++)
{
echo "<tr>";
for($r=0;$r<3;$r++)
{
for($c=0;$c<3;$c++)
{
echo "<td>".$product[$l][$r][$c]."</td>";
}
echo "</tr>";
}
}
echo "</table>";

I suggest you read Arrays Doc official