Hi everyone,
Is it possible in an email address such as: John Smith <johnsmith@home.ca> to remove everything before the first < and then remove the last > so that the email address becomes: johnsmith@home.ca?
Thanks.
PHP remove name and < > from email address
Moderator: General Moderators
Re: PHP remove name and < > from email address
Untested, but something like this should work.
Code: Select all
$email = preg_replace('/.*</', '', $email);
$email = rtrim($email, '>');Re: PHP remove name and < > from email address
it works however I had to modify it slightly:
$email = preg_replace('/.*</', '', $email);
$email = rtrim($email, '>');
echo $email;
thanks for the tip.
$email = preg_replace('/.*</', '', $email);
$email = rtrim($email, '>');
echo $email;
thanks for the tip.