/**
     * 编码改成utf-8
     * @param $str
     * @return bool|null|string|string[]
     */
    public static function strToUtf8($str)
    {
        $encode = mb_detect_encoding($str, ["ASCII", 'UTF-8', "GB2312", "GBK", 'BIG5']);
        if ($encode == 'UTF-8') {
            return $str;
        } else {
            return mb_convert_encoding($str, 'UTF-8', $encode);
        }
    }

关注友儿不迷路

Last modification:September 19th, 2020 at 11:34 pm
如果觉得我的文章对你有用,请随意赞赏