开发者

Trim blank lines from textarea submission

开发者 https://www.devze.com 2023-04-07 13:54 出处:网络
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_r

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

精彩评论

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