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

36次阅读

共计 481 个字符,预计需要花费 2 分钟才能阅读完成。

亲测可用解决

<?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);
 ?>

正文完
 0