note 12063 added to function.ucwords.php
| From: | neil at no-spam-ents24 dot com | Date: | Wed, 21 Mar 2001 10:10:07 +0000 |
| Subject: | note 12063 added to function.ucwords.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-12619@lists.php.net to get a copy of this message | ||
The code posted above by Joerg Krause only works for a string which ends with one of the delimiters.
A possible fix is:
$text = "What?No delimiters,shit happens here.this solves all problems.";
preg_match_all("/(\w+[,. ?])+/U", $text, $words);
preg_match("/(\w+)$/", $text, $lastword);
$words[0][] = $lastword;
foreach($words[0] as $part) $uwords[] = ucfirst($part);
$text = implode("", $uwords);
echo $text;
http://www.php.net/manual/en/function.ucwords.php