Menu Samaritan's Purse

ARRAY_REVERSE

Return an array with elements in reverse order

SYNTAX

array_reverse ( array $array [, bool $preserve_keys = FALSE ] ) : array

PARAMETERS

array

The input array.

preserve_keys

If set to TRUE numeric keys are preserved. Non-numeric keys are not affected by this setting and will always be preserved.

RETURN

Returns the reversed array.

EXAMPLES

ARRAY | INDEXED

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

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

ARRAY | ASSOCIATIVE

Array
(
    [c] => Array
        (
            [d] => 2
            [e] => 3
        )

    [b] => 1
    [a] => 0
)

PRESERVE_KEYS | INDEXED

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

    [1] => 1
    [0] => 0
)

PRESERVE_KEYS | ASSOCIATIVE

Array
(
    [c] => Array
        (
            [d] => 2
            [e] => 3
        )

    [b] => 1
    [a] => 0
)

PHP