An array is one of the very basic data structures. In an array, equally sized elements sequentially follow one another in a collection. In most languages these elements must be of the same type; however some programming languages, such as Perl, allow mixing types in arrays. Any element of this array can then be accessed through an index. Arrays can be multi-dimensional, resulting in a table structure (or a list of lists) instead of just a simple list of elements.
Each element in an array can be used just like a variable of the same type. Accessing an element is as simple as using an index number which can be either a literal number or the value stored in another variable. Some languages provide additional ways for accessing elements of arrays.
Here is an example of declaring and using a variable in C:
array = 0; array = 2; array = 3;
array = array + array;
Here an array of four integers is declared. Each element is accessed by an index and set to some value. The result stored in array would obviously be 5.
myarray : array(1..3) of integer; ... myarray(1) := 0; myarray(2) := 2; myarray(3) := 3;
myarray(1) := myarray(2) + myarray(3);
The value in myarray(1) is 5.
$array = 0; $array = 2; $array = 3;
$array = $array + $array;
The value stored in $array is 5.