php: replacing double
with

前端 未结 3 713
忘掉有多难
忘掉有多难 2021-01-17 14:22

i use nicEdit to write RTF data in my CMS. The problem is that it generates strings like this:

hello first line

this is a second line<
3条回答
  •  春和景丽
    2021-01-17 15:20

    This will work even if the two
    s are on different lines (i.e. there is a newline or any whitespace between them):

    function replace_br($data) {
        $data = preg_replace('#(?:\s*?){2,}#', '

    ', $data); return "

    $data

    "; }

提交回复
热议问题