Remove newline from string

/ Published in: PHP
Save to your folder(s)

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

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.