PHP - replace all "\n" Occurrences in a string -


i getting string in php output lots of \n characters convert <p> new line characters in html outpot.

i have tried following:

strtr($mystring, "\n", "<p>");     string_replace ("\n", "<p>", $mystring); 

both of these doesn't seems work. ideas what's wrong in syntax?

try this:

php:

<?php  $mystring = 'hello\nworld';  echo '<p>'. implode('</p><p>', explode('\n', $mystring)) .'</p>';  ?> 

output:

<p>hello</p><p>world</p> 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -