WEB TUTORIALS
PRACTICE EXAMPLES
HTML REFERENCES
CSS REFERENCES
PHP REFERENCES
Advertisements

How to reverse the order of an array in PHP

Topic: PHP / MySQLPrev|Next

Answer: 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("Red", "Green", "Blue");
 
// Printing the reversed array
print_r(array_reverse($colors));
?>

Related FAQ

Here are some more FAQ related to this topic:

Advertisements
Bootstrap UI Design Templates

Your Feedback:

We would love to hear from you, please drop us a line.