Opposite of nl2br? Is it str_replace?

后端 未结 8 1641
旧时难觅i
旧时难觅i 2020-12-02 00:07

So the function nl2br is handy. Except in my web app, I want to do the opposite, interpret line breaks as new lines, since they will be echoed into a pre-filled form.

<
8条回答
  •  既然无缘
    2020-12-02 00:55

    An alternative to @PascalMARTIN 's answer:

    $string = str_replace(array(
        '
    ', '
    ', '
    ', ), "\n", $string);

    It does not work with multiple white-spaces like
    but this should be a really rare case.

提交回复
热议问题