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
Post a Comment