Home > Backend Development > PHP Tutorial > How to remove newlines when reading files line by line in PHP

How to remove newlines when reading files line by line in PHP

WBOY
Release: 2016-07-25 09:13:13
Original
1020 people have browsed it

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

  1. //First type:

  2. $content=str_replace("n","",$content);
  3. echo $content;

  4. / /Or:

  5. $content=str_replace(array("n","r"),"",$content);

  6. //Second type:

  7. $content=preg_replace(" /s/","",$content);

  8. echo $content;

  9. //Third type:
  10. $content=trim($content);

Copy code


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