我目前在数据库中有很多笑话,这些笑话是用 nl2br() 格式化的,它产生......
This is just dummy text. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
<br /><br />
Vestibulum gravida justo in arcu mattis lacinia. Mauris aliquet mi quis diam euismod blandit ultricies ac lacus.
<br /><br />
Aliquam erat volutpat. Donec sed nisi ac velit viverra hendrerit.
<br />
Praesent molestie augue ligula, quis accumsan libero.
我需要一个 php 函数来转换<br /><br />
为 a <p></p>
,如果只有 1<br />
则不要管它。还修剪任何空白
所以最终的结果将是......
<p>This is just dummy text. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Vestibulum gravida justo in arcu mattis lacinia. Mauris aliquet mi quis diam euismod blandit ultricies ac lacus. </p>
Aliquam erat volutpat. Donec sed nisi ac velit viverra hendrerit.<br />
Praesent molestie augue ligula, quis accumsan libero.
有人可以指出我正确的方向或给我一个简单的功能吗?谢谢