2012-01-04 2 views
1
<textarea rows="18" cols="80" style="resize:none;"> 
<?php 
    $str = str_replace('<br>', '\n', 'some text<br><br>another line of text'); 
    echo($str); 
?> 
</textarea> 

出力は nはテキストエリアに動作していない

some text\n\nanother line of text 

これは私が欲しいの出力です。

some text 

another line of text 

誰でも問題がわかりますか? ありがとうございます

答えて

11

一重引用符で囲まれた円記号は、文字通り解釈されます。 official documentationを参照して、PHPで文字列リテラルを書くためのさまざまな方法の詳細については

$str = str_replace('<br>', "\n", 'some text<br><br>another line of text'); 
///      ^^ 

:あなたは二重引用符をしたいです。

+0

ありがとうございます –

関連する問題