开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜