array_reverse
Return an array with the opposite order of cells
array_reverse()
function returns the array in reverse element order.
Return the array in reverse order of elements:
<?php $a = array ( "a" => "Volvo" , "b" => "BMW" , "c" => "Toyota" ) ; print_r ( array_reverse ( $a ) ) ; ?>
Try it yourself
Return the original array, invert the array, and flipped array that retains the key names of the original array:
<?php $a = array ( "Volvo" , "XC90" , array ( "BMW" , "Toyota" ) ) ; $reverse = array_reverse ( $a ) ; $preserve = array_reverse ( $a , true ) ; print_r ( $a ) ; print_r ( $reverse ) ; print_r ( $preserve ) ; ?>
Try it yourself