在@之后使用str_replace删除
use str_replace to remove after @
如何在不使用单词数组的情况下使用 str_replace() 进行转向:
some@mail.com
进入
some
因此,“@”符号后的所有内容也包括 @。
我该怎么做?
例如,我将输入 'adminofsite@xxxwwweeerandomstuff.com'
输出将是:'adminofsite'.
function stripEmailDomain($string){
return substr($string, 0, strpos($string, '@'));
}
$str = "some@mail.com"
$str = substr($str,0,strpos($str,"@"))
使用strstr
$email="john@doe.com"
$user = strstr($email, '@', true);
echo $user;
我炸了,然后重建了字符串。如果您确定该字符串将始终是电子邮件地址,这将起作用。它是一种变通方法,但如果您想为特定目的修改它,它似乎很灵活。
<?php
$explo0= explode('@',"some@mail.com");
for($i=0;$i<count($explo0);$i++){
$exploresult0.=$explo0[$i+1];
}
echo "@".$exploresult0;
?>
如何在不使用单词数组的情况下使用 str_replace() 进行转向:
some@mail.com
进入
some
因此,“@”符号后的所有内容也包括 @。
我该怎么做?
例如,我将输入 'adminofsite@xxxwwweeerandomstuff.com'
输出将是:'adminofsite'.
function stripEmailDomain($string){
return substr($string, 0, strpos($string, '@'));
}
$str = "some@mail.com"
$str = substr($str,0,strpos($str,"@"))
使用strstr
$email="john@doe.com"
$user = strstr($email, '@', true);
echo $user;
我炸了,然后重建了字符串。如果您确定该字符串将始终是电子邮件地址,这将起作用。它是一种变通方法,但如果您想为特定目的修改它,它似乎很灵活。
<?php
$explo0= explode('@',"some@mail.com");
for($i=0;$i<count($explo0);$i++){
$exploresult0.=$explo0[$i+1];
}
echo "@".$exploresult0;
?>