当前位置:Gxlcms > PHP教程 > preg_replace('/[x7f-xff]/','A','直')的问题

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

时间:2021-07-01 10:21:17 帮助过:7人阅读

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


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


回复讨论(解决方案)

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

为什么要加个点啊

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




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

人气教程排行