$arr = file('./chinese.txt');
foreach($arr as $key =>$item) {
$arr[$key] = iconv('utf-8', 'gbk', trim($item, PHP_EOL));
}
asort($arr);
$fw = fopen('./sorted.txt','w');
foreach($arr as $key =>$item) {
fwrite($fw, iconv('gbk', 'utf-8', $item) . PHP_EOL);
}
fclose($fw);
foreach($arr as $key =>$item) {
$arr[$key] = iconv('utf-8', 'gbk', trim($item, PHP_EOL));
}
asort($arr);
$fw = fopen('./sorted.txt','w');
foreach($arr as $key =>$item) {
fwrite($fw, iconv('gbk', 'utf-8', $item) . PHP_EOL);
}
fclose($fw);