Sorting Arrays
Arrays are lists, and you will sort them differently, depending on the end-user requirements. PHP provides a library of predefined functions to sort arrays, as shown in Table 6-4. You will review the function definitions before examining each in depth.
Function | Description and Pattern |
---|---|
arsort() | The function takes two formal parameters: the first is an array, and the second is a sorting flag. It sorts in reverse or descending order, preserving the native keys of the original array, and has this pattern:
void arsort(array var [, int sort_flag]) |
asort() | The function takes two formal parameters: the first is an array, and the second is a sorting flag. It sorts in ascending order, preserving the native ... |
Get Oracle Database 10g Express Edition PHP Web Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.