/**
     * 编码改成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 19, 2020
如果觉得我的文章对你有用,请随意赞赏