Capturing linebreaks (newline,linefeed) characters in a textarea
问题 I have a form with a <textarea> and I want to capture any line breaks in that textarea on the server-side, and replace them with a <br/> . Is that possible? I tried setting white-space:pre on the textarea 's CSS, but it's still not enough. 回答1: Have a look at the nl2br() function. It should do exactly what you want. 回答2: The nl2br() function exists to do exactly this: However, this function adds br tags but does not actually remove the new lines - this usually isn't an issue, but if you want