An array in PHP is actually an ordered map. A map is a type that associates values to keys.
The array stores one or more similar type of values in a single value.
array( key => value, key2 => value2, key3 => value3, ... )
Each map is a key-value
pair.
The key
as also known as array index
.
The key can either be an integer
or a string
.
The value can be of any type.
<?php $fruits = array(0=>"Apple", 1=>"Orange", 2=>"Pear"); var_dump($fruits); echo "<br>"; $colors = array( "Red" => "#F00", "Green" => "#0F0", "Blue" => "#00F" ); var_dump($colors); ?>