Home > Backend Development > PHP Tutorial > strtr函数目字符替换出现乱码

strtr函数目字符替换出现乱码

WBOY
Release: 2016-06-13 12:40:36
Original
1068 people have browsed it

strtr函数字符替换出现乱码
我的替换词库来源于一个文本文件。文本文件无论改成gbk还是utf-8格式都出现乱码。
如果把替换词库自己定义如下:
$words = array('发文说'=>'DDDDDDDDDDDDDDDDDDDd');
替换就不会出现乱码
$data['content'] = strtr($data['content'], $words);

我把words变量打印出来,里面的词组都没有乱码,用函数检测,也不是utf-8格式。所以可以确认,内容和替换词组都是gbk格式的字符串。
请问如何解决这个问题?谢谢

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template