character encoding - replace \n to new line in string with php -
i want replace "\n" characters new line in string using php, :
string 'foo\n\nbar'
to
string 'foo bar`
anybody have idea ? thanks.
use str_replace('\n', php_eol, 'foo\n\nbar');
<?php header('content-type: text/plain'); $string = 'foo\n\nbar'; $string = str_replace('\n', php_eol, $string); echo $string; ?>
shows:
foo bar
Comments
Post a Comment