How to Trim special Character \r in php

Can anybody tell me here how to trim the special character rn or n in php? I know there is already trim function in php but that is not working.

While copying the email address from some other place and copying it into the excel field and during uploading i am getting the invalid email address error. But the email id is correct just due to the special character r the error is showing. Any help will be appreciated.

Thanks in advance


From PHP docs for trim() :

This function returns a string with whitespace stripped from the beginning and end of str. Without the second parameter, trim() will strip these characters:

" " (ASCII 32 (0x20)), an ordinary space.
"t" (ASCII 9 (0x09)), a tab.
"n" (ASCII 10 (0x0A)), a new line (line feed).
"r" (ASCII 13 (0x0D)), a carriage return.
"" (ASCII 0 (0x00)), the NUL-byte.
"x0B" (ASCII 11 (0x0B)), a vertical tab.

See example here: http://codepad.org/O9xa42cw


为什么不使用简单的str_replace()如果trim()真的不起作用(它实际上工作)?

<?php
$email = 'john@gmail.comr';
echo str_replace('r','',$email);

use

$email = str_replace('r', '', $email);

btw "r" is called carriage return char (you know old typewriters?)

链接地址: http://www.djcxy.com/p/69750.html

上一篇: 我如何验证唯一的电子邮件地址?

下一篇: 如何在PHP中修改特殊字符\ r