PHP Programing language

adplus-dvertising
array_reverse() Function in PHP
Previous Home Next
adplus-dvertising

array_reverse()

The array_reverse() function returns an array in the reverse order.

Syntax:
array_reverse(array,preserve)

In above syntax, "array" specifies an array and "preserve" specifies if the function should preserve the keys of the array or not and key values are as follows:

  • true
  • false

Example:

<?php
$arr=array("a"=>"Apple","b"=>"Mango","c"=>"Banana");
print_r(array_reverse($arr));
?>

Output:

Array ( [c] => Banana [b] => Mango [a] => Apple )

Previous Home Next