Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function array_reverse()


previous

Advertisements

Syntax

array_reverse ( $array [, $preserve_keys] );

Definition and Usage

This function reverse the order of all the elements of a padded array.

Paramters

ParameterDescription
arrayRequired. Specifies an array.
preserve_keysOptional. 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 )

previous Printer Friendly

Advertisements


  

Advertisements