The array_reverse()
function reverses the order of the elements in an array.
The basic syntax of the array_reverse()
function is given with:
array_reverse(array, preserve);
The array_reverse()
function accepts the following parameters.
Parameter | Description |
---|---|
array | Required. Specifies the array to work on. |
preserve | Optional. Specifies whether numeric keys should be preserved or not. Possible values are true and false . Non-numeric keys will always be preserved. |
Example1: following example reverse the order of array elements.
Output :
Array
(
[0] => Web
[1] => Designing
[2] => House
)
Example2 : The following example shows how to reverse the order of array elements while preserving the keys.
Output :