New line to paragraph function

前端 未结 7 1050
情话喂你
情话喂你 2021-01-31 09:20

I have this interesting function that I\'m using to create new lines into paragraphs. I\'m using it instead of the nl2br() function, as it outputs better formatted

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-31 09:46

    I also wrote a very simple version:

    function nl2p($text)
    {
        return '

    '.str_replace(array("\r\n", "\r", "\n"), '

    ', $text).'

    '; }

提交回复
热议问题