如何将电子邮件本地部分截断为“abc...@gmail.com”
我使用这个小函数在需要时截断字符串:
function truncate_text($text, $nbrChar = 55, $append='...') {
if (strlen($text) > $nbrChar) {
$text = substr($text, 0, $nbrChar);
$text .= $append;
}
return $text;
}
我需要一些帮助来创建一个新函数来截断电子邮件本地部分,类似于 Google 网上论坛中所做的操作。
[email protected]
这对于使用 Facebook 代理电子邮件的用户尤其有用。
[email protected]
我想这个新函数将使用正则表达式来查找 @
,然后将本地部分截断为一定数量的字符以生成类似的内容有
[email protected]
什么建议如何解决这个问题吗?
谢谢!
I use this little function to truncate strings when needed:
function truncate_text($text, $nbrChar = 55, $append='...') {
if (strlen($text) > $nbrChar) {
$text = substr($text, 0, $nbrChar);
$text .= $append;
}
return $text;
}
I would like some help to create a new function to truncate email local-parts similar to what is done in Google Groups.
[email protected]
This would be especially useful for users using Facebook's proxy email.
[email protected]
I guess this new function would use regex to find the @
and then truncate the local-part to a certain number of characters to generate something like
[email protected]
Any suggestions how to tackle this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此函数将截断电子邮件的第一部分(如果找到@)和其他字符串(如果找不到@)。
This function will truncate the first part of the email ( if the @ is found ) and other string if @ not found.