Remove newline from string


/ Published in: PHP



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);
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.