note 24732 deleted from function.ucwords by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 09:03:40 +0000 |
| Subject: | note 24732 deleted from function.ucwords by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-196868@lists.php.net to get a copy of this message | ||
Note Submitter: fille at fukt dot bth dot se
----
[Editor's note: For details on the bug see
http://bugs.php.net/bug.php?id=14655]
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.