May 2016
Intermediate to advanced
155 pages
2h 15m
English
© Mikael Olsson 2016
Mikael Olsson, PHP 7 Quick Scripting Reference, 10.1007/978-1-4842-1922-5_5
Mikael Olsson1
(1)Hammarland, Finland
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 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 ...Read now
Unlock full access