PHP Arrays

From Techotopia
Revision as of 15:03, 1 June 2007 by Neil (Talk | contribs) (New page: PHP Arrays provide a way to group together many variables such that they can be referenced and manipulated using a single variable. An array is, in many ways, a self-contained list of vari...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

PHP Arrays provide a way to group together many variables such that they can be referenced and manipulated using a single variable. An array is, in many ways, a self-contained list of variables.

Once an array has been created items can be added, removed and modified, sorted and much more. The items in an arrasy can be of any variable type and an array can contain any mixture of data types - it is not necessary to have each element in the array of the same type.

Elements of an array are accessed using a key. There are two types of array depending on the type of key that is used to access an array element. In a numerical key array elements are accessed by specifying the numerical position of the item in the array. The first item in an array is element 0, the second is element 1 and so on. The second type of array is the associative array where a name is given to each element

Creating a PHP Array