解决PHP-strreplace方法转换GBK个别中文乱码问题

亲测可用解决

<?php
                //解决个别中文乱码
                function mbStrreplace($content,$to_encoding="UTF-8",$from_encoding="GBK") {
                    $content=mb_convert_encoding($content,$to_encoding,$from_encoding);
                    $str=mb_convert_encoding(" ",$to_encoding,$from_encoding);
                    $content=mb_eregi_replace($str," ",$content);
                    $content=mb_convert_encoding($content,$from_encoding,$to_encoding);
                    $content=trim($content);
                    return $content;
                }

                $follow_up_message = str_replace("。","。</br>",$data['follow_up_message']);
                echo mbStrreplace($follow_up_message);
 ?>

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理