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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -