Current Location: Home> Function Categories> array_reverse

array_reverse

Return an array with the opposite order of cells
Name:array_reverse
Category:Array
Programming Language:php
One-line Description:Returns the array in reverse order.

Definition and usage

array_reverse() function returns the array in reverse element order.

Example

Example 1

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

Example 2

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

Similar Functions
Popular Articles