PHP:如何摆脱像“\u00a0”这样的奇怪字符?

夏期劇*_*期劇場 1 php special-characters hidden-characters non-breaking-characters

我有一堆乱七八糟的 JSON 数据要导入到我的数据库中(用于进一步目的)。当我检查它们(在文本编辑器中打开)时,它们包含许多奇怪(胡言乱语)的字符,例如:

  • \u00a0

例如data.json

[{"title":"hello world!","html_body":"<p>Hello\u00a0 from the\u00a0  other side.\u00a0 <\/p>"}]
Run Code Online (Sandbox Code Playgroud)

然后,显然,下面的代码根本行不通:

$clean = str_replace("\u00a0", "", $string);
Run Code Online (Sandbox Code Playgroud)

不管这些角色是干什么用的,我怎么能摆脱它们呢?

夏期劇*_*期劇場 6

感谢评论部分的每个人,他们(至少)帮助我知道那些是non-breaking characters. 然后我用谷歌搜索,无论如何我自己找到了一个可行的解决方案:

$clean_html_body = preg_replace('/\xc2\xa0/', '', $html_body);
Run Code Online (Sandbox Code Playgroud)

再次感谢大家。:)