note 24732 modified in function.ucwords by jmcastagnetto
| From: | jmcastagnetto@php.net | Date: | Tue, 27 Aug 2002 22:36:11 +0000 |
| Subject: | note 24732 modified in function.ucwords by jmcastagnetto | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-35814@lists.php.net to get a copy of this message | ||
[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.
--was--
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