array_reverse

PHP 4, PHP 5, PHP 7, PHP 8
array_reverse - Return an array with elements in reverse order

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

Takes an input array and returns a new array with the order of the elements reversed.

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 Values

Returns the reversed array.

Related Functions

Example of array_reverse

Show all examples for array_reverse

PHP Version:


Function array_reverse:

Arrays Functions

Most used PHP functions