PHP array_reverse() function

PHP array_replace_recursive() function
PHP array_search() function

The array_reverse function reverses the elements of the given array and returns them. For instance, the first element of the array will appear at the last and the last will appear at the first applying this transition to the elements in between.

What is the syntax of the array_reverse function in PHP?

array_reverse(array, preserve)
arrayThe array to reverse the elements of – Required
preserveBoolean parameter – When set to true: Preserve the keys of the array while reversing. When set to false: keys are not preserved while reversing – Optional
array_reverse function in PHP

Example of array_reverse function



In the above example, we print the original array, reversed array, and the reversed array with preserved parameter set to true. Run this script to have the best understanding of the array_reverse function.

PHP array_replace_recursive() function
PHP array_search() function
en English
Scroll to Top