Home >Backend Development >PHP Tutorial >3 ways to remove newlines when reading files line by line in PHP_PHP Tutorial

3 ways to remove newlines when reading files line by line in PHP_PHP Tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-13 10:30:46870browse

PHP reads the file line by line and removes the newline character "n":

First type:

Copy code The code is as follows:
$content=str_replace("n","",$content ; (array("n","r"),"",$content);
Second type:

Copy code Code As follows:
$content=preg_replace("/s/","",$content);
echo $content;
Third type:
Copy code The code is as follows:
$content=trim($content);



http://www.bkjia.com/PHPjc/764614.htmlwww.bkjia.com
true

http: //www.bkjia.com/PHPjc/764614.htmlTechArticle

PHP reads the file line by line and removes the newline character "n": Type 1: Copy the code The code is as follows: $content =str_replace("n","",$content); echo $content; Or: Copy the code as follows: $...
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