PHP » Arrays

An array is a datatype that can hold multiple instances of other datatypes. In PHP there are two types of arrays, numerically indexed and associative. The elements of a numerically indexed array are referenced with a numerical index enclosed in [] brackets. For example, $my_array[1] would be the second element in $my_array. Associative arrays are not limited to using numbers for indexing. Instead "keys" in the form of strings are used to reference elements. This can be useful for pairing of data. For example, the names of husbands could be mapped to the names of their wives like this: $couples["Jonathan"] = "Mindy";

Arrays can also be multidimensional. To reference an element in a two-dimensional array, double indexes are used: $my_array[1][2].