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

WBOY
Release: 2016-07-13 10:30:46
Original
837 people have browsed it

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: $...
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