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
)
More arrays PHP Questions
How can I loop through the members of an array?I am not interested in the values in the arrays, how can I discard them?
How do I remove an element from an array without changing the index values for the rest of the array?
How do I return all the values in an array?
How do I turn an array into a string?