Trim blank lines from textarea submission
I have a form that submits text from textarea. The text can be formatted, i.e. have line breaks and paragraphs, however I want to remove blank lines at the end of the text. Shall I use rtrim or preg_replace?
Can I use something like this to clear blank lines, carriage returns and tab开发者_开发技巧s?
rtrim($_POST['inviteMsg'], "\n\t\r");
Yes. In fact, that's precisely what rtrim
is for. preg_replace
just offers you loads of extra flexibility that you don't need in this case.
精彩评论