Created
August 8, 2013 17:39
-
-
Save iowillhoit/6186825 to your computer and use it in GitHub Desktop.
Changes uppercase sequences to lowercase and wraps in a span with the "text-transform:uppercase" style. This is helpful to lower your spam rating on email newsletters. Most spam filters don't like seeing ALL CAPS, because it's usually IS spam..
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 | |
function replaceUpperCaseWithCss($matches){ | |
$lower = strtolower($matches[0]); | |
return sprintf('<span style="text-transform:uppercase;">%s</span>', $lower); | |
} | |
function findUpperCaseSequences($text){ | |
return preg_replace_callback("/[^a-z\ ]{2,}(\ [^a-z\ ]+)*\b/", "replaceUpperCaseWithCss", $text); | |
} | |
$string = "I CAN! DO mutliple WO-RDS, but I ignore WORDS with One Capital Letter"; | |
echo findUpperCaseSequences($string); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment