Q:

How to reverse the order of an array in PHP

0

How to reverse the order of an array in PHP

All Answers

need an explanation for this answer? contact us directly to get an explanation for this 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));
?>

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

PHP  and MySQL Frequently Asked Questions

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
How to check if a key exists in an array in PHP... >>
<< How to display array structure and values in PHP...