Reliably Remove Newlines From String

前端 未结 6 1162
忘了有多久
忘了有多久 2020-12-21 06:52

The string input comes from textarea where users are supposed to enter every single item on a new line.

When processing the form, it is easy to explode the textarea

6条回答
  •  孤城傲影
    2020-12-21 07:10

    '\r' by itself as a line terminator is an old convention that's not really used anymore (not since OSX which is Unix based).

    Your explode will be fine. Just trim off the '\r' in each resulting element for the Windows users.

提交回复
热议问题