Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php strstr在发生前显示字符串_Php_Strstr - Fatal编程技术网

Php strstr在发生前显示字符串

Php strstr在发生前显示字符串,php,strstr,Php,Strstr,我想得到针出现后的第一个字符串位,就像这样 $user = strstr('someemail@yahoo.com', '@', true); 但这只适用于PHP版本5.3.0,我有5.2.9 有什么方法可以得到同样的结果吗?我本来打算用strstr推荐strpos,但后来我发现这个答案已经让我的建议相形见绌了。答案不错,你还能用$user访问用户名吗?或者这会将其存储在列表中吗? list($user, $therest) = explode('@',$email);

我想得到针出现后的第一个字符串位,就像这样

$user = strstr('someemail@yahoo.com', '@', true); 
但这只适用于PHP版本5.3.0,我有5.2.9
有什么方法可以得到同样的结果吗?

我本来打算用
strstr
推荐
strpos
,但后来我发现这个答案已经让我的建议相形见绌了。答案不错,你还能用$user访问用户名吗?或者这会将其存储在列表中吗?
list($user, $therest) = explode('@',$email);