Log in

View Full Version : Capitalise First Letter of Post/Sentence


thetradingforum
05-04-2007, 03:26 PM
I've seen the various "capitalise" mods around the forum, but none work for me.

Hope someone can tell me how to do this.

I would like to capitalise the first letter of every post on my forum, and also capitalise the first letter of each sentence. To avoid capitalising in URLs, I want the system to only capitalise after a "FULL STOP+ SPACE", so in other words ". "
So links containing .com won't appear as .Com because the Full stop doesn't have a Space after it.

Hope you get what I mean.

Thanks,:D

RedTyger
05-04-2007, 06:55 PM
$sentences = explode('. ', $post['message']);
foreach ($sentences AS $sentence)
{
$post .= ucfirst($sentence).'. ';
}
$post['message'] = $post;


That should work. You split the post into chunks by every period-space (which removes the period-space), then for each chunk you capitalise the first letter, add the period and space back on and add it to a new temporary post. Then you replace the original post with your temp post.

You have the function, now just got to make it into a plugin and find the right place to put it in the code. Good luck...