note 72718 added to function.ucfirst
| From: | zee at osu1 dot php dot net | Date: | Wed, 31 Jan 2007 00:09:48 +0000 |
| Subject: | note 72718 added to function.ucfirst | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-122381@lists.php.net to get a copy of this message | ||
Another way to capitalize first letter of every sentence in a text, I hope it will help someone. It
won't convert non-English characters, though, and ignores sentences ending with ! or ? etc.
<?php
$text="this is a sentence. this is another sentence.";
$split=explode(". ", $text);
foreach ($split as $sentence) {
$sentencegood=ucfirst($sentence);
$text=str_replace($sentence, $sentencegood, $text);
}
echo $text; // This is a sentence. This is another sentence.
?>
----
Server IP: 195.70.37.52
Probable Submitter: 84.0.240.228
----
Manual Page -- http://www.php.net/manual/en/function.ucfirst.php
Edit -- https://master.php.net/note/edit/72718
Del: integrated -- https://master.php.net/note/delete/72718/integrated
Del: useless -- https://master.php.net/note/delete/72718/useless
Del: bad code -- https://master.php.net/note/delete/72718/bad+code
Del: spam -- https://master.php.net/note/delete/72718/spam
Del: non-english -- https://master.php.net/note/delete/72718/non-english
Del: in docs -- https://master.php.net/note/delete/72718/in+docs
Del: other reasons-- https://master.php.net/note/delete/72718
Reject -- https://master.php.net/note/reject/72718
Search -- https://master.php.net/manage/user-notes.php