for ($i = 0, $size = count($array); $i < $size; $i++) {
...
}
do the following:
for ($i = count($array) - 1; $i >=0 ; $i--) {
...
}
However, as always, use a for loop only on a
tightly packed array.
Another alternative would be, if possible, to invert the order
elements are placed into the array. For instance, if
you're populating an array from a series of rows
returned from a database, you should be able to modify the query to
ORDER DESC. See your database manual for the exact
syntax for your database.