sphinx Posted November 28, 2011 Share Posted November 28, 2011 Hello, I'm currently using this to block certain emails: $blacklisted = Array("email@email.com", "email2@email.com", "email3@email.com"); in with: if( !in_array( strtolower($email), $blacklisted ) ) { Ok, What I want to do, is be able to specify a domain extension such as '*@email.com' So anything with 'something'@email.com is blocked. I still wish to keep manual email address's in place aswell. Many thanks James Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted November 28, 2011 Share Posted November 28, 2011 you can use strstr() to find the domain in the string. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 29, 2011 Share Posted November 29, 2011 This worked for me: <?php $blacklistArr = array("email@email.com", "email2@email.com", "email3@email.com", "@gmail.com"); function isBL($e){ global $blacklistArr; $isBlackListed = false; foreach($blacklistArr as $email){ $email = preg_quote($email); if(preg_match("/$email/i", $e)){ $isBlackListed = true; break; } } return $isBlackListed; } $tests = array("email@email.com", "myemail@gmail.com", "email23@email.com", "email2@email.com", "mike@yahoo.com"); foreach($tests as $email){ echo "$email: "; var_dump(isBL($email)); echo "<br>"; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.