2013-03-31, 04:30 AM
Turns out I'd deleted it, but it was easy enough to figure out the code again. Ignore the comments, it's part of a project I'm working on.
Notes:
- This is slightly more reliable than the OP, as with that, a single punctuation mark can cause it not to parse.
- Sentences will lack grammar correction: I's will not be capitalized, and new sentences aren't capitalized. It's probably possible to do both, but this is a very basic example.
// Do a tad of fancy examination
if((strlen($message) / 2) < strlen(preg_replace('![^A-Z]+!', '', $message)))
{
// Half the message is uppercase.
// User is (probably) trying to SHOUT.
$message = ucfirst(strtolower($message));
}
Notes:
- This is slightly more reliable than the OP, as with that, a single punctuation mark can cause it not to parse.
- Sentences will lack grammar correction: I's will not be capitalized, and new sentences aren't capitalized. It's probably possible to do both, but this is a very basic example.
Please don't PM me for support.