字符串转码成特定字符集编码

//获取字符串编码字符集$encode
$encode = mb_detect_encoding($string, array('ASCII', 'UTF-8', 'GB2312', 'GBK', 'BIG5'));

//设置转码
if($encode != 'UTF-8'){
  $string = iconv($encode, 'UTF-8', $html);  
}
echo $string;

 

posted @ 2014-11-21 11:26  胡小扯  阅读(293)  评论(0)    收藏  举报