note 85372 added to function.ucwords

From: Date: Wed, 27 Aug 2008 16:43:26 +0000
Subject: note 85372 added to function.ucwords
Groups: php.notes 
Request: Send a blank email to php-notes+get-143890@lists.php.net to get a copy of this message
A modified sentenceNormalizer by gregomm Features: 1- Removes duplicated question marks, exclamations and periods 2- Capitalize first letter of a sentence. 3- Split sentences not only with "." but also with "?" and "!" 4- Puts a white space at the end of each sentence 5- Retains newlines --removed from orginal function-- undestand the meaning of "¡" and "¿" in languages like spanish. undestand the htmlentitity version of this simbols. --removed from orginal function-- <?php function sentenceNormalizer($sentence_split) { $sentence_split = preg_replace(array('/[!]+/','/[?]+/','/[.]+/'), array('!','?','.'),$sentence_split); $textbad = preg_split("/(\!|\.|\?|\n)/", $sentence_split,-1,PREG_SPLIT_DELIM_CAPTURE); $newtext = array(); $count = sizeof($textbad); foreach($textbad as $key => $string) { if (!empty($string)) { $text = trim($string, ' '); $size = strlen($text); if ($size > 1){ $newtext[] = ucfirst(strtolower($text)); } elseif ($size == 1) { $newtext[] = ($text == "\n") ? $text : $text . ' '; } } } return implode($newtext); } ?> ---- Server IP: 208.69.120.35 Probable Submitter: 69.9.62.220 ---- Manual Page -- http://www.php.net/manual/en/function.ucwords.php Edit -- https://master.php.net/note/edit/85372 Del: integrated -- https://master.php.net/note/delete/85372/integrated Del: useless -- https://master.php.net/note/delete/85372/useless Del: bad code -- https://master.php.net/note/delete/85372/bad+code Del: spam -- https://master.php.net/note/delete/85372/spam Del: non-english -- https://master.php.net/note/delete/85372/non-english Del: in docs -- https://master.php.net/note/delete/85372/in+docs Del: other reasons-- https://master.php.net/note/delete/85372 Reject -- https://master.php.net/note/reject/85372 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#143890) next »