Menu Samaritan's Purse

ARRAY_FILL

Fill an array with values

SYNTAX

array_fill ( int $start_index , int $num , mixed $value ) : array

PARAMETERS

start_index

The first index of the returned array. If start_index is negative, the first index of the returned array will be start_index and the following indices will start from zero

num

Number of elements to insert. Must be greater than or equal to zero.

value

Value to use for filling

RETURN

Returns the filled array

EXAMPLES

START_INDEX | ZERO

Array
(
    [0] => abc
    [1] => abc
    [2] => abc
    [3] => abc
    [4] => abc
)

START_INDEX | NEGATIVE

Array
(
    [-5] => abc
    [0] => abc
    [1] => abc
    [2] => abc
    [3] => abc
)

START_INDEX | POSITIVE

Array
(
    [5] => abc
    [6] => abc
    [7] => abc
    [8] => abc
    [9] => abc
)

NUM | ZERO

Array
(
)

NUM | POSITIVE

Array
(
    [0] => abc
    [1] => abc
    [2] => abc
    [3] => abc
    [4] => abc
    [5] => abc
    [6] => abc
    [7] => abc
    [8] => abc
    [9] => abc
)

VALUE | BOOLEAN

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

VALUE | INTEGER

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

VALUE | FLOAT

Array
(
    [0] => 1.2
    [1] => 1.2
    [2] => 1.2
    [3] => 1.2
    [4] => 1.2
)

VALUE | STRING

Array
(
    [0] => abc
    [1] => abc
    [2] => abc
    [3] => abc
    [4] => abc
)

VALUE | ARRAY

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

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

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

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

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

)

VALUE | OBJECT

Array
(
    [0] => stdClass Object
        (
        )

    [1] => stdClass Object
        (
        )

    [2] => stdClass Object
        (
        )

    [3] => stdClass Object
        (
        )

    [4] => stdClass Object
        (
        )

)

PHP