考虑以下代码
<?php
// The new line separated string
$section_string = <<<EOL
Sentence A1. Sentence A2. Sentence A3.
Sentence B1. Sentence B2. Sentence B3.
Sentence C1. Sentence C2. Sentence C3.
EOL;
// Is there a function you can call like so:
$html_markup = unknown_awesome_function( $section_string );
echo $html_markup;
?>
预期产量
<p>Sentence A1. Sentence A2. Sentence A3.</p><p>Sentence B1. Sentence B2. Sentence B3.</p><p>Sentence C1. Sentence C2. Sentence C3.</p>
而不是虚构的例子
unknown_awesome_function()
, 是否有内置函数可以调用以生成多个
<p>
基于带有新行分隔符的字符串的标记?
最合适的回答,由SO网友:WebElaine 整理而成
你试过了吗apply_filters(\'the_content\', $section_string)
? 这应该应用wp\\u autop,它将添加<p>
标签或<br>
s