乐趣区

解决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);
 ?>
退出移动版