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 can I check if a value is already in an array?sort
How can I loop through the members of an array?
How can I create an array of the letters of the alphabet?
How do I check if a variable is of array type?
