Voting

: max(eight, seven)?
(Example: nine)

The Note You're Voting On

Ken Kehler
18 years ago
@ zee: this should solve your !, ?, and any punctuations you want to add. It can probably be cleaned up a bit.

<?php

function sentence_cap($impexp, $sentence_split) {
$textbad=explode($impexp, $sentence_split);
$newtext = array();
foreach (
$textbad as $sentence) {
$sentencegood=ucfirst($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; // This is a sentence. This is another sentence! This is the fourth sentence? No, this is the fourth sentence.

?>

<< Back to user notes page

To Top