public static function strToGBK($strText)
    {
        $encode = mb_detect_encoding($strText, array('UTF-8','GB2312','GBK'));
        if($encode == "UTF-8")
        {
            return @iconv('UTF-8','GB18030',$strText);
        }
        else
        {
            return $strText;
        }
    }
mb_detect_encoding:检测字符的编码

 程序猿必读

posted on 2016-09-26 19:50  龙种人  阅读(7022)  评论(0编辑  收藏  举报