Home  >  Article  >  Backend Development  >  PHP怎么去掉字符里的控制字符

PHP怎么去掉字符里的控制字符

WBOY
WBOYOriginal
2016-06-06 20:46:54796browse

我采集到的信息里经常出现:
DLE Data Link Escape (数据链路转义)
当有这个控制字符的时候,做json_encode() json_decode().就会失败。 请问如何把这种控制字符去掉呢?

回复内容:

我采集到的信息里经常出现:
DLE Data Link Escape (数据链路转义)
当有这个控制字符的时候,做json_encode() json_decode().就会失败。 请问如何把这种控制字符去掉呢?

<code class="lang-php">preg_replace( '/[\x00-\x1F]/','',$str);
</code>
Statement:
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