In this tutorial, we are going to learn about how to reverse an array of elements in PHP.
To reverse an array in PHP, we can use the built-in array_reverse() function.
The array_reverse() function takes the array as an argument and returns the array of elements in reverse order.
Here is an example.
$fruits = array("oranges", "mangoes", "grapes"); $reverse = array_reverse($fruits); print_r($reverse);
Array (  => grapes  => mangoes  => oranges )
Note: The above
array_reverse() function doesn’t modifies the original array instead of it creates a new one with modified values.
You can also checkout the following tutorials for more knowledge: