Home >Backend Development >PHP Tutorial >请问怎么截取邮箱地址的最后面的后缀

请问怎么截取邮箱地址的最后面的后缀

WBOY
WBOYOriginal
2016-06-23 14:21:161392browse

比如
tsy0rcz9xlr7m75@m.marketplace.amazon.co.jp
tsy0rcz9xlr7m75@m.amazon.de.jp

我要截取最后面的jp


@后面的.的数量是不一定的,有多有少的


回复讨论(解决方案)

我是要获取最后一个后缀jp

substr($str, strrpos($str, '.')+1)


应该可以 ,没有 测试 呀!

echo pathinfo('tsy0rcz9xlr7m75@m.amazon.de.jp', PATHINFO_EXTENSION);//jp

echo pathinfo('tsy0rcz9xlr7m75@m.amazon.de.jp', PATHINFO_EXTENSION);//jp
+1

用PHP自带的函数效率高且简洁!
pathinfo() 返回一个关联数组包含有 path 的信息。

http://www.w3school.com.cn/php/func_filesystem_pathinfo.asp

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn