-
- 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);
- ?>
复制代码
输出结果:
Array
(
[griffin] => peter
[swanson] => joe
[quagmire] => glenn
[Griffin] => Peter
[Swanson] => Joe
[Quagmire] => Glenn
)
>>> 更多内容,请查看 php数组排序方法大全
|