How to remove line breaks with PHP or JS

前端 未结 4 985
臣服心动
臣服心动 2021-01-14 20:31

I\'ve tried about everything to delete some extra \\n characters in a web application I\'m working with. I was hoping someone has encountered this issue before

4条回答
  •  情书的邮戳
    2021-01-14 21:12

    In javascript, the .replace() method doesn't modify the string. It returns a new modified string, so you need to reference the result.

    text = text.replace(/\n/g,"")
    

提交回复
热议问题