mysql - PHP如何去除从Linux文件读出来的特殊字符

WBOY
Release: 2016-06-06 20:48:15
Original
1098 people have browsed it

在linux文件里每一行记录一个字符串,如——I波纹管
当我通过PHP从文件里读出这一行数据时,变成了——I^B波纹管,多了“^B”,我该如何去除这种类似的特殊字符?

回复内容:

在linux文件里每一行记录一个字符串,如——I波纹管
当我通过PHP从文件里读出这一行数据时,变成了——I^B波纹管,多了“^B”,我该如何去除这种类似的特殊字符?

不知道这里的 ^B 是不是那个 ascii code 为 2 的一个字符
参考这里:http://www.robelle.com/smugbook/ascii.html

如果真的是它的话,在 PHP 中,可以用这种方式取得/替换这个字符:

<code class="lang-php">$str = 'some string';
$ctrl_b = chr(2);

$new_str = str_replace($ctrl_b, '', $str);
</code>
Copy after login

参考这里:http://us1.php.net/chr

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!