Menu Riverview Church

ARRAY

Create an array

SYNTAX

array ( [ mixed $... ] ) : array

PARAMETERS

...

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

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.

EXAMPLES

EMPTY

Array
(
)

ONE-DIMENSIONAL

Array
(
    [0] => 0
    [1] => 1
)

TWO-DIMENSIONAL

Array
(
    [fruits] => Array
        (
            [a] => orange
            [b] => banana
            [c] => apple
        )

    [numbers] => Array
        (
            [0] => 1
            [1] => 2
            [2] => 3
            [3] => 4
            [4] => 5
            [5] => 6
        )

    [holes] => Array
        (
            [0] => first
            [5] => second
            [6] => third
        )

)

AUTOMATIC INDEX

Array
(
    [0] => 1
    [1] => 1
    [2] => 1
    [3] => 13
    [4] => 1
    [8] => 1
    [9] => 19
)

1-BASED INDEX

Array
(
    [1] => January
    [2] => February
    [3] => March
)

INSIDE DOUBLE QUOTES

Hello World!

PHP