This function accepts array as source and return an array with elements in reverse order.
array array_reverse(array source [, bool preserve_keys])
array_reverse accepts two parameters:
array as source
preserve_keys Set TRUE or FALSE, if set to TRUE numeric keys are preserved.
The following example shows how to reverse an indexed array of strings:
$count = array("zero", "one", "two", "three"); $countdown = array_reverse($count); print_r($count); print_r($countdown);
//$count result Array ( => zero  => one  => two  => three) //$countdown result Array ( => three  => two  => one  => zero)
Setting the optional preserve_keys argument to
true reverses the order but preserves the association between the index and the elements. For a numerically indexed array, this means that the order of the elements is reversed, but the indexes that access the elements don't change. This might seem a bit weird, but the following example shows what is happening:
$count = array("zero", "one", "two", "three"); $countdown = array_reverse($count, true); print_r($countdown);
Array ( => three  => two  => one  => zero)