explode()并返回数据

时间:2014-04-30 19:53:01

标签: php irc

我有一个这样的字符串:

  

:username!~tHesR5 @ tHesR5.users.quakenet.org

我需要的是这个字符串:

  

~tHesR5@tHesR5.users.quakenet.org

我已经使用以下内容从字符串中获取了用户名:

        $nick = explode(':',$get[0]);
        $nick = explode('!',$nick[1])
        $nick = $nick[0];

我如何正确地检索“!”之后的内容?

3 个答案:

答案 0 :(得分:1)

就像那样......

$strWhoIs = ":username!~tHesR5@tHesR5.users.quakenet.org";

$arrWhois = explode('!', $strWhoIs);
$strFirstPart = $arrWhois[0];
$strSecondPart = $arrWhois[1];

请参阅文档:php.net/explode

答案 1 :(得分:0)

$nick = explode(':',$get[0]);
$nick = explode('!',$nick[1])
$username = $nick[1]; // <-- add this line
$nick = $nick[0];

答案 2 :(得分:0)

$nick = substr( $get[0], 10 );怎么样?