PrimitiveType

Array

An array is a data structure consisting of a collection of items. In some languages, such as Java, arrays have a fixed size and must be declared to hold items of a certain type. In other languages, such as PHP, an array's size can be changed throughout the course of the program and can hold different data types in each position.

In a traditional array, each position in the array is identified by a number, known as the index or subscript. Often the range of numbers starts at zero, so that the first the position is identified by 0, the second by 1, and so on, though this is not the case for all languages.

In an "associative" array, text labels, or keys, can be used to name and identify positions. For example, the following PHP snippet declares an array element belonging to the array $properties to have the key "colour" and the value "blue":

$properties['colour'] = 'blue';

See ALL glossary entries