Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

Here I've used reset to put the internal array pointer at the first element. I then get each
following element with the next function. This is the order in which the elements exist
in memory, but they retain their original indices, which are the numbers starting with zero
that were used when the elements were added to the array.


If I had used arsort, the order would have been the exact opposite. Listing 15.5 is
perhaps a more typical use of these functions. It is important to keep the elements in the
array returned by getdate associated with their indices. Listing 15.5 sorts the array
in reverse order by the elements. It may not be particularly useful but illustrates the use of
this function.


Listing 15.4 Using the asort Function

Free download pdf