我有特定的字符串
$email = "[email protected]";
我想清理并从字符串中删除+1,它也可以是任何数字+1或+99,因此最终的字符串可以是
$email = "[email protected]";
我不知道该怎么办,我尝试创建此方法,但是它给了我这个输出。
$email = jaymingmail.com;
下面是我的功能:
public function delete_all_between($beginning, $end, $string) {
$beginningPos = strpos($string, $beginning);
$endPos = strpos($string, $end);
if ($beginningPos === false || $endPos === false) {
return $string;
}
$textToDelete = substr($string, $beginningPos, ($endPos + strlen($end)) - $beginningPos);
return $this->delete_all_between($beginning, $end, str_replace($textToDelete, '', $string)); // recursion to ensure all occurrences are replaced
}
$out = $this->delete_all_between('+', '@', $email);
谁能帮我解决我要去的地方。
我需要删除+1或+号后的任何数字。