note 73895 added to function.ucfirst

From: Date: Wed, 14 Mar 2007 20:03:04 +0000
Subject: note 73895 added to function.ucfirst
Groups: php.notes 
Request: Send a blank email to php-notes+get-124451@lists.php.net to get a copy of this message
@ 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. ?> ---- Server IP: 64.71.164.2 Probable Submitter: 64.19.44.182 ---- Manual Page -- http://www.php.net/manual/en/function.ucfirst.php Edit -- https://master.php.net/note/edit/73895 Del: integrated -- https://master.php.net/note/delete/73895/integrated Del: useless -- https://master.php.net/note/delete/73895/useless Del: bad code -- https://master.php.net/note/delete/73895/bad+code Del: spam -- https://master.php.net/note/delete/73895/spam Del: non-english -- https://master.php.net/note/delete/73895/non-english Del: in docs -- https://master.php.net/note/delete/73895/in+docs Del: other reasons-- https://master.php.net/note/delete/73895 Reject -- https://master.php.net/note/reject/73895 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#124451) next »