|
|
Php Array Elements Reverse Function
|
Tutorials » Php »
|
Topic |
What is array_reverse Function?
|
|
Explanation |
|
The "array_reverse" function returns an array with elements in reverse order.
Syntax:
array_reverse(array,preserve)
In the above syntax "array" specifies the array, "preserve" is used to preserve the array keys, it can either be
true or false.
Example:
<?php
$b=array("c"=>"Cherry","b"=>"Strawberry");
print_r(array_reverse($b);
?>
Result:
Array ([b]=> Strawberry, [c]=> Cherry)
In the above example the function returns the array elements in the reverse order.
|
|
A Note |
Learn PHP programming language tutorial with simple and neat example. Hope you enjoy this free tutorial.
Do give us your valuable feedback and suggestions on this online tutorial. This is a Copyright Content.
|
|
|
|