Home >Backend Development >PHP Tutorial >preg_replace('/[x7f-xff]/', 'A', '直')的问题

preg_replace('/[x7f-xff]/', 'A', '直')的问题

WBOY
WBOYOriginal
2016-06-20 12:33:441197browse

preg_replace('/[\x7f-\xff]/', 'A', '直');


php.ini  GBK
为什么替换后是AA,怎么变成A?


回复讨论(解决方案)

preg_replace('/[\x7f-\xff]./', 'A', '直');

为什么要加个点啊

gbk 汉字是 2 个字节
而 [\x7f-\xff] 只是一个字节,所以要加个 . 补齐




终于懂了,谢谢大版主。。。。。。

Statement:
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