note 50729 added to function.ucwords
| From: | iguano-spamatcoveruniversedotcom at osu1 dot php dot net | Date: | Tue, 08 Mar 2005 12:30:19 +0000 |
| Subject: | note 50729 added to function.ucwords | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-86100@lists.php.net to get a copy of this message | ||
The code posted by neil doesn't fully do what is wanted. Try adding some more question marks at
the end and it will return a not wanted string.
Below code will uppercase all your words regardless of the delimiter.
<?php
$text = "What?No 'delimiters',shit \"happens\" here.this solves all
problems???";
preg_match_all('/[A-Za-z]+|[^A-Za-z]+/', $text, $data);
for ($i = 0; $i < count($data[0]); $i++) {
$data[0][$i] = ucfirst($data[0][$i]);
}
$text = implode("", $data[0]);
print $text;
?>
----
Manual Page -- http://www.php.net/manual/en/function.ucwords.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50729
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50729&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50729&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50729&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50729&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50729&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50729&report=yes
Search -- http://master.php.net/manage/user-notes.php