August 2013
Intermediate to advanced
140 pages
1h 49m
English
CHAPTER 5
![]()
Arrays
An array is used to store a collection of values in a single variable. Arrays in PHP consist of key-value pairs. The key can either be an integer (numeric array), a string (associative array) or a combination of both (mixed array). The value can be any data type.
Numeric arrays
Numeric arrays store each element in the array with a numeric index. An array is created using the array constructor. This constructor takes a list of values which are assigned to elements of the array.
$a = array(1,2,3);
As of PHP 5.4 a shorter syntax is available, where the array constructor is replaced with square brackets.
$a = [1,2,3];
Once the ...
Read now
Unlock full access