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

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

WBOY
Release: 2016-06-20 12:33:44
Original
1189 people have browsed it

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


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


回复讨论(解决方案)

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

为什么要加个点啊

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




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

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