note 24732 added to function.ucwords
| From: | fille at fukt dot bth dot se | Date: | Tue, 27 Aug 2002 12:04:32 +0000 |
| Subject: | note 24732 added to function.ucwords | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-35722@lists.php.net to get a copy of this message | ||
This function has a bug, and while waiting for the bug fix, here is a work-around pice of code.
When using international letters, you will get into troubles with the ucwords() function.
Example:
$string="xxxöxx" will be "XxxöXxx" after beeing processed by ucwords().
To get around it, I wrote some extra code that checks the string once more, and lowercases all
letters that is not in the beginning of a word.
$string=ucwords($string);
//Bugfix from here on
for($i=0;$i<strlen($string);$i++)
if((ctype_upper($string[$i]) &&( $string[$i-1]==" " || $i==0 ))!=TRUE)
$string[$i]=strtolower($string[$i]);
Thia code is also an optional way of doing the same work on a string that is totally UPPERCASE.
--
http://www.php.net/manual/en/function.ucwords.php
http://master.php.net/manage/user-notes.php?action=edit+24732
http://master.php.net/manage/user-notes.php?action=delete+24732
http://master.php.net/manage/user-notes.php?action=reject+24732