In PHP (and unlike most other programming languages that implement them) arrays are a means of grouping any number of different variables, regardless of type, into a single variable. Technically, arrays actually represent an ordered map that maps key values to pieces of variable data (see ). The contents of a value pointed to by a key in an array can be anything represented by a PHP variable; there is no limit (other than memory) imposed on the maximum number of different keys a single array can possess. There are a number of ways to declare arrays, each of which is discussed in the sections that follow.
Array Syntax
In PHP, you can create an array variable in various ways. Perhaps the simplest way to implement arrays is through the following syntax:
$variable[<key expr>] = <expr>;
<key expr> is an expression that evaluates to a string or any non-negative integer, and <expr> represents the expression whose value will be associated with the key. is an example of an array $foo, which contains four keys, a, b, c, and d, assigned the integer values 1, 2, 3, and 4, respectively: