I have a function that is suppose to make the first character of all sentences uppercase, but for some reason, it's not doing it to the first character of the first sentence. Why is that happening, and how do I fix it?
<?php
function ucAll($str) {
$str = preg_replace_callback('/([.!?])\s*(\w)/',
create_function('$matches', 'return strtoupper($matches[0]);'), $str);
return $str;
} //end of function ucAll($str)
$str = ucAll("first.second.third");
echo $str;
?>
Result:
first.Second.Third
Expected Result:
First.Second.Third