您可以usort()
使用自定义排序功能对其进行排序。如果您想查看它如何适合您自己的自定义详细信息,您可以修改此数据:http: //codepad.org/b89HwmbM
$members = array(
array( "loc" => "Ontario", "first" => "Bob", "screen_name" => "fooArt" ),
array( "loc" => "Atlanta", "first" => "Sal", "screen_name" => "TIMMY!" ),
array( "loc" => "Panama", "first" => "Mick", "screen_name" => "Analog" ),
array( "loc" => "Pensacola", "first" => "A", "screen_name" => "Franky" ),
array( "loc" => "McPherson", "first" => "Anna", "screen_name" => "annie9" )
);
usort( $members, 'custom_sort' );
function custom_sort( $m1, $m2 ){
return strtolower( $m1['screen_name'] ) > strtolower( $m2['screen_name'] );
};
此排序方法的输出如下:
Array
(
[0] => Array
(
[loc] => Panama
[first] => Mick
[screen_name] => Analog
)
[1] => Array
(
[loc] => McPherson
[first] => Anna
[screen_name] => annie_23
)
[2] => Array
(
[loc] => Ontario
[first] => Bob
[screen_name] => fooArt
)
[3] => Array
(
[loc] => Pensacola
[first] => A
[screen_name] => Franky
)
[4] => Array
(
[loc] => Atlanta
[first] => Sal
[screen_name] => TIMMY!
)
)