Reliably Remove Newlines From String

前端 未结 6 1154
忘了有多久
忘了有多久 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:03

    You can normalize the input:

     "\n",
        "\r" => "\n",
        "\n" => "\n",
    ));
    
    ?>
    

    Alternatively, you can explode with regular expressions:

    
    

提交回复
热议问题