Name

array

Synopsis

array array([mixed ...])

Creates an array using the parameters as elements in the array. By using the => operator, you can specify specific indexes for any elements; if no indexes are given, the elements are assigned indexes starting from 0 and incrementing by one. The internal pointer (see current , reset , and next ) is set to the first element.

$array = array("first", 3 => "second", "third", "fourth" => 4);

Note: array is actually a language construct, used to denote literal arrays, but its usage is similar to that of a function, so it’s included here.

Get Programming PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.