Search

How to reverse the order of an array in PHP

PHP
post-title

Use the PHP array_reverse() function

You can use the PHP array_reverse() function to reverse the order of the array elements.

Let's try out an example to understand how this function actually works:

<?php
$colors = array("Harsukh", "Asmita", "Chetan", "Kishan");
 
// Printing the reversed array
print_r(array_reverse($colors));
?>