Php array_reverse array Reverse Order
Array_reverse
(PHP 4 and PHP 5)
Array_reverse-returns an array whose content order is reversed.
Description
Array array_reverse (array $ array [, Boolean $ preserve_keys = false])
Use a command to input an array and return a new array to reverse the content.
Parameters
Array
Input array.
Preserve_keys
If this parameter is set to TRUE, the key is saved.
Return Value
Returns the reverse array.
Modify
Version description
The preserve_keys parameter of 4.0.3 is added.
Instance
Example #1 array_reverse ()
<? Php
$ Input = array ("php", 4.0, array ("green", "red "));
$ Result = array_reverse ($ input );
$ Result_keyed = array_reverse ($ input, true );
?>
This makes both $ result and $ result_keyed have the same elements, but note the difference between the keys. The printout of $ result and $ result_keyed will be:
Array
(
[0] => Array
(
[0] => green
[1] => red
)
[1] => 4
[2] => php
)
Array
(
[2] => Array
(
[0] => green
[1] => red
)
[1] => 4
[0] => php
)