How do I reverse the order of the elements in an array?
<?php
$countup = range(1,5);
print_r($countup);
$countdown = array_reverse($countup);
print_r($countdown);
?>
This will output the following:
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
)
Array
(
[0] => 5
[1] => 4
[2] => 3
[3] => 2
[4] => 1
)
Comment on this Question and Answer >>>
ASK A QUESTION
More arrays PHP Questions
How do I remove the first element from an array?How can I sort a multi-dimensional array?
How can I display values in a two dimensional array?
what is a array?
How do I find if a value is already in an array or not?
