Tutorials

Learn web design and programming with our free video and text tutorials.

Web Designer? Design and market your own professional website with easy-to-use tools.

PHP Arrays

A PHP arrays can be thought of as a list. An array allows you to refer to a list of values with a single variable.

Values in an array can be any type of data type, this allows you to store numbers, strings, objects and other arrays within an array. Arrays also allow you to store any combination of numbers, strings, objects and other arrays within an array.

Values in arrays are accessed through the use of keys, which are similar to variable names in that they are the name that is used to locate a specific value. A key can not be used for multiple values within the same array.

There are 3 different kinds of arrays in PHP:

PHP Numeric Arrays
Numeric arrays allow you to access the values in the array in numeric order through the use of numeric ID keys.

PHP Associative Arrays
Associative arrays allow you to access the values in the array through the use of named string ID keys for each stored value.

PHP Multi-Dimensional Arrays
A multi-dimensional array is an array value that is set to another array within the main array, which is basicaly a list within a list.