Definition
The array_reverse() function returns an array in the reverse order.
Syntax
array_reverse(array, preserve)
Parameters
Parameter | Description |
---|---|
array |
Required. Specifies an array. |
preserve |
Optional. Specifies if the function should preserve the keys of the array or not. Possible values: true ; false |
Example
<?php
// Example 1
$ages = array("Mark" => 22, "Jeff" => 32, "Mike" => 28);
print_r(array_reverse($ages));
echo "<br>";
// Example 2
print_r(array_reverse($ages, true));
echo "<br>";