复制代码 代码如下:
function cmp($a, $b){
if ($a["vote_num"] == $b["vote_num"]) {
return 0;
}
return ($a["vote_num"] > $b["vote_num"]) ? -1 : 1;
}
$arr = Array
(
0 => Array
(
o_id => 1861,
o_name => 2,
o_pic => 'http://g.vevb.com/image.gif' ,
o_detail => 人人,
vote_num => 1
),
1 => Array
(
o_id => 1844,
o_name => 芭比,
o_pic => 'http://upload.vevb.com/game_image/dfxxz/dfVIP.files/shenxiandao.jpg',
o_detail => 也是美女呢,
vote_num => 2
),
2 => Array
(
o_id => 1843,
o_name => 程程,
o_pic => 'http://g.vevb.com./upload_img/2011-06/31554_4d0088da7a61ad9c8c02a530be94d98e.png',
o_detail => 美女哦,
vote_num => 3
)
);
uasort($arr, ”cmp“);
echo ‘< pre >';
print_r ($arr);
echo ‘< / pre >';
复制代码 代码如下:
Array
(
[2] => Array
(
[o_id] => 1843
[o_name] => 程程
[o_pic] =>
[o_detail] => 美女哦
[vote_num] => 3
)
[1] => Array
(
[o_id] => 1844
[o_name] => 芭比
[o_pic] =>
[o_detail] => 也是美女呢
[vote_num] => 2
)
[0] => Array
(
[o_id] => 1861
[o_name] => 2
[o_pic] =>
[o_detail] => 人人
[vote_num] => 1
)
)
新闻热点
疑难解答