Heim >Backend-Entwicklung >PHP-Tutorial >请问怎么截取邮箱地址的最后面的后缀

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 14:21:161441Durchsuche

比如
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

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn