PHP, strip_tags stripping \n in text area. How to stop it?

后端 未结 1 1756
野的像风
野的像风 2021-01-18 16:02

I would like to be able to accept \\n or \\r\\n and convert them to
for use in the page. Although when a user submits a t

相关标签:
1条回答
  • 2021-01-18 16:29

    You can use nl2br to add the BR line break element to line break character sequences:

    $html = nl2br($plain);
    

    Note that the BR elements are just added:

    nl2br("foo\nbar") === "foo\n<br />bar"
    

    And to prevent strip_tags to remove P and BR tags, specify them in the second parameter:

    $clean = strip_tags($html, '<p><br>');
    
    0 讨论(0)
提交回复
热议问题