Posted By

dmistriotis on 10/11/10


Tagged

php String line newline


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

cjmling


Remove newline from string


 / Published in: PHP
 

  1. // To remove it, simply replace it with an empty string like this :
  2. $str = str_replace("\n", "", $str);
  3.  
  4. //Also, if you want it to be reflected in your HTML you should replace the \n with <BR>.
  5. $str=nl2br($str);
  6.  
  7. //Or
  8. $str = str_replace("\n", "<BR>", $str);

Report this snippet  

You need to login to post a comment.