note 10313 deleted from function.ucwords by victor

From: Date: Sat, 12 Jun 2004 21:02:44 +0000
Subject: note 10313 deleted from function.ucwords by victor
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-70982@lists.php.net to get a copy of this message
Note Submitter: joerg@krause.net ---- None of the examples above recognizes characters normally used as delimiters. The following uses a regular expression, which is easy to extend, to create an array with the parts of a text. Then it runs the ucfirst-function for each part an implode the array: $text = "What?No delimiters,shit happens here.this solves all problems."; preg_match_all("/(\w+[,. ?])+/U", $text, $words); foreach($words[0] as $part) $uwords[] = ucfirst($part); $text = implode("", $uwords); echo $text; Joerg Krause www.php.comzept.de www.joergkrause.de/krause

« previous php.notes (#70982) next »