note 109572 deleted from function.ucfirst by danbrown
| From: | danbrown@php.net | Date: | Mon, 30 Jul 2012 15:47:16 +0000 |
| Subject: | note 109572 deleted from function.ucfirst by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-189473@lists.php.net to get a copy of this message | ||
Note Submitter: fmmarzoa at gmail dot com
----
The code from chris at bjelleklang dot org 26-Jan-2011 03:03 does not work. Try it with Spanish word
"ñocla", for example.
The problem is that as refering to $str[0] you are just changing the first byte, but in a MULTIBYTE
string you should need to change more than one.
This ACTUALLY works:
function mb_ucfirst($str){
$orig = mb_substr($str,0,1);
$target = mb_strtoupper($orig);
$str = $target.mb_substr($str,1);
return $str;
}