I have a function that takes a string and convert’s the words to proper case (upper/lower case). For some reason, word’s that have an ‘ in them, it capitalizes the next letter after the ‘. Could someone help me fix this? The code is below:
[code]
if ($case_magic == ‘y’) {
// now capitalize all first-letters of words, getting around php’s
// inability to recognized non-word delimiters
$title = preg_replace (“/(W?)(w+)(W?)/e”,
“‘\1’.ucwords(strtolower(‘\2’)).’\3′”, $title);
// these are the words that we don’t want first-letter-capitalized…
$words=array( ” a “,
” and “,
” the “,
” for “,
” to ” ,
” an ” ,
” on “);
foreach ($words as $w) {
$title=str_replace( ucwords(strtolower($w)), strtolower($w),$title);
}
}
Thanks.