-
- function my_sort($a, $b)
- {
- if ($a == $b) return 0;
- return ($a > $b) ? -1 : 1;
- }
- $people = array("Swanson" => "Joe",
- "Griffin" => "Peter", "Quagmire" => "Glenn",
- "swanson" => "joe", "griffin" => "peter",
- "quagmire" => "glenn");
- uasort($people, "my_sort");
- print_r ($people);
- ?>
Copy code
Output result:
Array
(
[griffin] => peter
[swanson] => joe
[quagmire] => glenn
[Griffin] => Peter
[Swanson] => Joe
[Quagmire] => Glenn
)
>>> For more information, please view the complete list of php array sorting methods
|