array

PHP 4, PHP 5, PHP 7, PHP 8
array - Create an array

array( ... mixed$values ): array

Creates an array. Read the section on the array type for more information on what an array is.

Parameters

values

Syntax "index => values", separated by commas, define index and values. index may be of type string or integer. When index is omitted, an integer index is automatically generated, starting at 0. If index is an integer, next generated index will be the biggest integer index + 1. Note that when two identical index are defined, the last overwrite the first.

Having a trailing comma after the last defined array entry, while unusual, is a valid syntax.

Return Values

Returns an array of the parameters. The parameters can be given an index with the => operator. Read the section on the array type for more information on what an array is.

Notes

Note:

array is a language construct used to represent literal arrays, and not a regular function.

Related Functions

Example of array

Show all examples for array

PHP Version: