Learning PHP
Advanced PHP
PHP Function Reference
PHP Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM
|
PHP Function array_reverse()
Syntax
array_reverse ( $array [, $preserve_keys] );
|
Definition and Usage
This function reverse the order of all the elements of a padded array.
Paramters
Parameter | Description |
array | Required. Specifies an array. |
preserve_keys | Optional. Specifies if order of keys also has to be changed ofr not. By default its FALSE. |
Return Values
Return an array with elements in reverse order.
Example
Try out following example:
<?php
$array=array("a"=>"banana","b"=>"apple","c"=>"orange");
print_r(array_reverse($array));
?>
|
This will produce following result:
Array ( [c] => orange [b] => apple [a] => banana )
|
|
|
|