如何在PHP脚本中使用UTF-8
字符?
我知道有一个转义字符可以将下一个字符解释为UTF-8
。这个转义字符是\s
。所以\xFF
可以工作,它将代表'ÿ
'。
但现在我想从字符串中删除零宽空格(U+200B
)。怎么做呢?我可以使用str_replace()
函数,或者也可以使用preg_replace()
函数吗?
先感谢您的帮助。
这对我起作用了:
$str = str_replace("\xe2\x80\x8b", '', $str);
来源:
您可以尝试使用 mb_ereg_replace()
或者 iconv()
与 str_replace。
http://www.php.net/manual/en/function.mb-ereg-replace.php
http://hu.php.net/manual/en/function.iconv.php
删除零宽空格:
$str = str_replace(chr(13), "", $str);
chr(13)
不是零宽度空格。 - Brad Koch