PHP Questions Home
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

How do I reverse the order of the elements in an array?


This is easy to do in PHP - as with most common things you might like to do with an array, there is already a nice PHP function to take the strain for you. So no need to concoct your own function - just use the built-in power of PHP to do it for you, a little like this:

<?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
)



ASK A QUESTION

More arrays PHP Questions

How do I pick a random value from an array?

i have a site named profile.php where i want to replace the following: http://www.youtube.com/watch?v=yoXE031j8d0 into: i know i could use str_replace to replace into ... but i need to know the URL so i can check if it rea

How do I remove an element from an array without changing the index values for the rest of the array?

Translation Composition Nationalism European Grammar Arabic Poetry Prose ******************************* I want an array equation that helps me to calculate some of varibles unspecific

how a values entered in an array from keyboard?



Custom Search