Home  >  Article  >  Backend Development  >  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
WBOYOriginal
2016-07-25 09:13:13998browse

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


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