PHP截取两个字符串之间的内容

<?
    echo $a2."<br/>";
    $p1 = strpos($a2,'clientindex:')+12;
    $p2 = strpos($a2,'name:') - $p1 -1;
    echo substr($a2,$p1,$p2);
?>

若$a2 = "2013/09/09 00:07:43[wextfunc.cpp:325] 尝试登录. clientindex:7175 name:afei0025 key:e10adc3949ba59abbe56e057f20f883e client.version:1.1 server.version:1.1 "

则打印:7175

你可能感兴趣的:(字符串)