replace br tag from a string in php

后端 未结 5 1174
抹茶落季
抹茶落季 2021-01-02 07:39

I have the following string. I want to replace the line break with /n

Good FRIENDS are hard to find,
harder to leave,
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-02 08:17

    Use str_replace

    $text = str_replace("
    ", "\n", $text);

    If there is actually a line break within the
    tag as in your sample code, try this:

    $text = preg_replace("//", "\n", $text);
    

提交回复
热议问题