Created
May 11, 2016 11:43
-
-
Save stevenkellow/94e0e53ad3bf5a2c4f9a5d617cff1879 to your computer and use it in GitHub Desktop.
Fix common spelling mistakes in email addresses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $hotmail_string = "[email protected]"; | |
| $gmail_string = "[email protected]"; | |
| // Array of misspelled email address parts | |
| $hotmail_wrong = array('hitmail', 'hitnail', 'hotnail', 'hotmain', 'hitmain'); | |
| $gmail_wrong = array('gmali.com', 'gmail.co.uk', 'gamil.com'); | |
| // Check all hotmail versions | |
| foreach($hotmail_wrong as $h_check){ | |
| if (strpos($hotmail_string, $h_check) !== false) { | |
| $hotmail_new = str_replace($hotmail_wrong, 'hotmail', $hotmail_string); | |
| } | |
| } | |
| // Check all gmail versions | |
| foreach($gmail_wrong as $g_check){ | |
| if (strpos($gmail_string, $g_check) !== false) { | |
| $gmail_new = str_replace($gmail_wrong, 'gmail.com', $gmail_string); | |
| } | |
| } | |
| // Display - but you can do something more fun! | |
| echo $hotmail_new . '<br/>'; | |
| echo $gmail_new; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment