多维数组排序
<?phpheader("Content-type: text/html; charset=utf-8");
$data[] = array('name' => '张三', 'fen' => 90,);
$data[] = array('name' => '李四', 'fen' => 30);
$data[] = array('name' => '王五', 'fen' => 60);
//排序前
echo "<pre>";
print_r($data);
echo "</pre>";
// 取得列的列表
foreach ($data as $key => $row) {
$fen[$key] = $row['fen'];
}
// ASC根据 fen 升序排列
array_multisort($fen,SORT_ASC, $data);
//排序后
echo "<pre>";
print_r($data);
echo "</pre>";
?>
页:
[1]