How to reverse the order of an array in PHP
array_reverse()
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)); ?>
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Use the PHP
array_reverse()functionYou 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:
need an explanation for this answer? contact us directly to get an explanation for this answer