我有一个字符串:
"Hello\u00c2\u00a0World"
我想转换为:
"Hello World"
我尝试:
str_replace("\u00c2\u00a0"," ","Hello\u00c2\u00a0World");
或者
str_replace("\\u00c2\\u00a0"," ","Hello\u00c2\u00a0World");
但不行!
我有一个字符串:
"Hello\u00c2\u00a0World"
我想转换为:
"Hello World"
我尝试:
str_replace("\u00c2\u00a0"," ","Hello\u00c2\u00a0World");
或者
str_replace("\\u00c2\\u00a0"," ","Hello\u00c2\u00a0World");
但不行!
解决!
str_replace(chr(194).chr(160)," ","Hello\u00c2\u00a0World");
这应该工作
$str="Hello\u00c2\u00a0World";
echo str_replace("\u00c2\u00a0"," ",$str);
如果您想删除 \u.... 之类的模式,那么您可以使用它,例如:
$string = preg_replace('/(\\\u....)+/',' ',$input);
你是那里的大部分。
$stuff = "Hello\u00c2\u00a0World";
$newstuff = str_replace("\u00c2\u00a0"," ",$stuff);
您需要将 str_replace 的返回值放入一个变量中,以便稍后对其进行处理。