Forcing Capitalization with PHP

I am using this simple php code to force thread titles to capitalize the first letter of each word:


$smallwords = array( 'a','of','the');

$words = explode(' ', $vbulletin->GPC['subject']);

foreach ($words as $key => $word) {
    if (!$key or !in_array($word, $smallwords)) $words[$key] = ucwords($word);
 }

$vbulletin->GPC['subject'] = implode(' ' , $words);

I also want to be able to force certain words to be ALL CAPS in the title… do you know what I would need to add to this code to specify certain words so that they will always be caps when displayed in the titles? Thanks!

I like your attention to grammatical detail there! Are your words that you want to be all caps similar to this - I mean a small, predefined selection? Could you not just do a similar thing with strtoupper()?

Yes, I think that’s it - but I cannot get it to work with vBulletin for some reason. Any ideas?

Anyone have any tips for how I implement the strtoupper() into the code in my first post, to specify all caps for certain words on vBulletin? Thanks!