php中文排序

方式一 需要数据库支持gbk
select distinct(id) as member_id, member_name from members order by convert(member_name using gbk) asc

方式二 在程序中排序


public function arraySort($arr,$sort = 'asort'){           
if(empty($arr) || !is_array($arr))               
return false;           
$arr_gbk = array();           
$arr_utf = array();           
foreach($arr as $key => $value){                   
$value = iconv('UTF-8','GBK',$value);                   
$arr_gbk[$key] = $value;          
}           
$sort($arr_gbk);           
foreach($arr_gbk as $key => $value){               
$value = iconv('GBK','UTF-8',$value);               
$arr_utf[$key] = $value;          
}           
return $arr_utf;      
}

你可能感兴趣的:(PHP)