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 count the number of times a value appears in an array?how sorting an array with keys?
How do I reverse sort an array by key?
HOW CAN I DELETE ALL THE ELEMENT OF THE ARRAY
I want to invert my array, can I do this?
