Ken and zee
One thing I would do to make this more unviersally work would be to add strtolower() around your $sentence. Doing this will allow you to convert an all caps text block as well as an all lowercase text block.
<?php
function sentence_cap($impexp, $sentence_split) {
$textbad=explode($impexp, $sentence_split);
$newtext = array();
foreach ($textbad as $sentence) {
$sentencegood=ucfirst(strtolower($sentence));
$newtext[] = $sentencegood;
}
$textgood = implode($impexp, $newtext);
return $textgood;
}
$text = "this is a sentence. this is another sentence! this is the fourth sentence? no, this is the fourth sentence.";
$text = sentence_cap(". ",$text);
$text = sentence_cap("! ",$text);
$text = sentence_cap("? ",$text);
echo $text; ?>