PHP MYSQL fetching a TEXT with new lines

后端 未结 3 700
慢半拍i
慢半拍i 2020-12-11 06:18


        
相关标签:
3条回答
  • 2020-12-11 06:44

    Maybe nl2br is what are you looking for?

    0 讨论(0)
  • 2020-12-11 06:45

    Use this:

    echo nl2br($result[msg]);
    

    As long as browsers doesn't treat \r\n as real new-lines - you need to "convert" them to <br>'s with nl2br()

    0 讨论(0)
  • 2020-12-11 06:57

    Also you can use:
    REPLACE(`col_name`,"\n","<br />") as `col_name`
    You must use this after SELECT.

    Example code:
    SELECT *, REPLACE(`name`,"\n","<br />") as `name` FROM xyz WHERE id="%s"

    0 讨论(0)
提交回复
热议问题