This may come as a bit of a shock to you, but PHP's arrayfunctions can do a lot more than just count the elements of an array oriterate through key-value pairs. This article takes an in-depth look atPHP's less well-known array manipulation tools, illustrating how they canbe used to write tighter, more efficient code...and have some fun in thebargain as well!
If you need to, you can rearrange the elements within an array with PHP's numerous sorting functions. The simplest of these is the array_reverse() function, which merely reverses the order of elements within an array.
The usort() function lets you apply your own sort function to
the elements of an array. The function that you define must be capable of comparing two values, and must return a positive, negative or zero value depending on whether the first value being compared is greater than, less than or equal to the second value.
An example might help to make this clearer. The following code snippet defines a custom sort function, which arranges elements according to their length.