Its prototype follows:
void rsort(array array [, int sort_flags])
An example follows:
$states = array("Ohio","Florida","Massachusetts","Montana");
rsort($states);
print_r($states);
It returns the following:
Array ( [0] => Ohio [1] => Montana [2] => Massachusetts [3] => Florida )
If the optional sort_flags parameter is included, the exact sorting behavior is
determined by its value, as explained in the sort() section.
Sorting an Array in Reverse Order While Maintaining Key/Value Pairs
Like asort(), arsort() maintains key/value correlation. However, it sorts the array in
reverse order. Its prototype follows:
void arsort(array array [, int sort_flags])
An example follows:
$states = array("Delaware","Pennsylvania","New Jersey");
arsort($states);
print_r($states);
It returns the following:
Array ( [1] => Pennsylvania [2] => New Jersey [0] => Delaware )
If the optional sort_flags parameter is included, the exact sorting behavior is
determined by its value, as described in the sort() section.
150 CHAPTER 5 ?– ARRAYS
Sorting an Array Naturally
The natsort() function is intended to offer a sorting mechanism comparable to the
mechanisms that people normally use. Its prototype follows:
void natsort(array array)
The PHP manual offers an excellent example, shown here, of what it means to sort
an array ???naturally.??? Consider the following items: picture1.jpg, picture2.
Pages:
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230