Need Help with filter_var()
Posted: Wed Aug 29, 2012 12:46 pm
Hello:
I am trying to extract email addresses from a larger string. Following is my current attempt:
For the most part everything is working fine. But with one email content the filter_var() is not functioning properly. Specifically:
Thanks Much:
Pavilion
I am trying to extract email addresses from a larger string. Following is my current attempt:
Code: Select all
foreach(preg_split('/ /', $string) as $token) {
echo "Token: " . $token ."<br />";
$email = filter_var(filter_var($token, FILTER_SANITIZE_EMAIL), FILTER_VALIDATE_EMAIL);
$AdminAddress = stripos($email, "admin@mysite");
if ($AdminAddress !==0 && $email !== false) {
echo "EMAIL: " . $email . "<br />";
$emails[] = $email;
}
//return $emails;
}- The Token echo is returning: DDuck@yahoo.com Subject: Notice the space between .com and Subject
- After the $token is run through filter_var() it returns the following: JAminson@yahoo.comSubject. Subject is now added to the email address.
Thanks Much:
Pavilion