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

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

WBOY
Release: 2016-06-06 20:46:54
Original
854 people have browsed it

我采集到的信息里经常出现:
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>
Copy after login
Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template