数据在文本文件,导出到excel出现乱码,utf-8输出,将字符转成gbk ok
<?php
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=number.xls");
///header('Content-type:text/html;charset=utf-8');
$arr = file('./xml/number.txt');
foreach ($arr as $item) {
$item = str_replace(array('\r\n','\n','\t', PHP_EOL),'',trim($item));
$tmp = explode('#',$item);
echo iconv('utf-8','gbk',$tmp[0]) . "\t"; // 关键
echo iconv('utf-8','gbk',$tmp[1]) . "\t\n";
}