我需要从下面的 html 代码中检索电子邮件数据
<a href="mailto:contact@rovio.com" rel="nofollow">Email Developer</a>
我已使用此代码获取电子邮件地址,但未能获取。
preg_match('@^(?:mailto:)?([^/]+)@i', $data, $matches);
$email = $matches[1];
echo $email;
你能看出什么问题吗?
我需要从下面的 html 代码中检索电子邮件数据
<a href="mailto:contact@rovio.com" rel="nofollow">Email Developer</a>
我已使用此代码获取电子邮件地址,但未能获取。
preg_match('@^(?:mailto:)?([^/]+)@i', $data, $matches);
$email = $matches[1];
echo $email;
你能看出什么问题吗?
What you just can do is
$string = '<a href="mailto:contact@rovio.com" rel="nofollow">Email Developer</a>';
$parsing = new SimpleXmlElement($string);
$attrs = (array)$parsing->attributes();
$mail = str_replace('mailto:','',$attrs['href']);
if(filter_var($mail,FILTER_VALIATE_MAIL)){//if it is a good email
//goooo
}