English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The PHP array_reverse() function returns an array with the elements in reverse order
array_reverse ( $array [, $preserve_keys] );
The array_reverse() function accepts an array as input and returns a new array with the elements in reverse order.
Serial Number | Parameters and Description |
---|---|
1 | array(Required) It specifies an array. |
2 | preserve_keys(optional) It specifies whether the order of the keys must also be changed. The default is FALSE. |
It returns the reversed array.
Reverse the order of the specified array
<?php $input = array("a"=>"banana","b"=>"mango","c"=>"orange"); print_r(array_reverse($input)); ?>Test and See‹/›
Output Result
Array ( [c] => orange [b] => mango [a] => banana )