uasort

bool uasort(array array, string func) 
array Array to be sorted
func Function to use for sorting

Sorts an array by value with a user-defined function.

Returns:

TRUE on success; FALSE on failure

Description:

uasort() sorts array by the value of each element, using the specified user-defined function named by func . Key/value relationships are preserved. This function is useful if the values of an associative array must be in some specific non-regular order, such as when you want to do a non-case-sensitive sort with both uppercase and lowercase alphabets.

func should be written to accept two parameters, which it must compare with each other. If they’re considered equivalent, 0 should be returned. If the first is considered to be greater, ...

Get PHP Functions Essential Reference 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.