如何添加两个break'&书信电报;br>';在php中使用nl2br()标记?

如何添加两个break'&书信电报;br>';在php中使用nl2br()标记?,php,Php,我正在使用nl2br()函数插入标记 现在我想插入两个标记。可能吗?这应该可以满足您的要求: $string = str_replace("<br>", "<br><br>", $string); $string=str_replace(“”,“”,$string); nl2br将把添加到换行符中,将替换为stru replace 如果您想添加,可以添加第二个参数FALSE来告诉函数这不是xhtml nl2br($yourContent, FALSE) 像

我正在使用nl2br()函数插入

标记


现在我想插入两个

标记。可能吗?

这应该可以满足您的要求:

$string = str_replace("<br>", "<br><br>", $string);
$string=str_replace(“
”,“

”,$string);
nl2br将把

添加到换行符中,将

替换为
stru replace

如果您想添加

,可以添加第二个参数FALSE来告诉函数这不是xhtml

nl2br($yourContent, FALSE)
像这样:

str_replace('<br>', '<br><br>',nl2br($yourContent, FALSE));
str_replace(“
”、“

”、nl2br($yourContent,FALSE));
或者这个:

str_replace('<br />', '<br /><br />',nl2br($yourContent));
str_替换('
','

',nl2br($yourContent));
编辑: 这对我来说很有用:

$test = nl2br(nl2br("The nutty pearl barley,
sweetly caramelised carrots and heady garlic combine to make these simple ingredients
into a seriously special dinner. (Serves 4) 46p a portion 4 carrots, diced, 40p 2 tsp
")); 

echo $test;
原帖(错了啊哈)

你可以这么做

$string = nl2br($string);
$string = str_replace('<br>', '<br><br>', $string);
$string=nl2br($string);
$string=str_replace(“
”、“

”、$string);

$string=nl2br($string);
$string=str_replace('
','

',$string);
使用nl2br()两次尝试
$string=nl2br(nl2br($string))我使用了它,但它没有替换。尝试将4 br替换为2br,如此stru replace(“



”、“

”、nl2br($string));这太奇怪了,我帮不了你更抱歉了^^让我们在phpcodeonline$test=nl2br中试试这个(nl2br)(“坚果珍珠大麦,甜焦糖胡萝卜和令人兴奋的大蒜结合在一起,使这些简单的成分成为一顿非常特别的晚餐46便士一份4份胡萝卜,切成丁,40便士2茶匙混合干草药,6便士300克珍珠大麦,33便士将胡萝卜放入一个大炒锅中,加入两汤匙油。用中高火炒10分钟,直到边缘开始焦糖化。加入洋葱、大蒜、蘑菇和混合草药,以及剩下的蔬菜);echo str_替换(“
”、“test”、$test”);
$string = nl2br($string);
$string = str_replace('<br />', '<br /><br />', $string);