note 103907 modified in function.ucfirst by danbrown
| From: | danbrown@php.net | Date: | Wed, 11 May 2011 15:47:50 +0000 |
| Subject: | note 103907 modified in function.ucfirst by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-179629@lists.php.net to get a copy of this message | ||
if you want to ucfirst for utf8 try this one:
<?php
function ucfirst_utf8($stri){
if($stri{0}>="\xc3")
return (($stri{1}>="\xa0"))?
($stri{0}.chr(ord($stri{1})-32)):
($stri{0}.$stri{1});
else return ucfirst($stri{0});
}
?>
It is quick, not language (but utf8) dependend and does not use any mb-functions such as mb_ucfirst.
--was--
if you want to ucfirst for utf8 try this one:
function ucfirst_utf8($stri){
if($stri{0}>="\xc3")
return (($stri{1}>="\xa0"))?
($stri{0}.chr(ord($stri{1})-32)):
($stri{0}.$stri{1});
else return ucfirst($stri{0});
}
It is quick, not language (but utf8) dependend and does not use any mb-functions such as mb_ucfirst.
http://php.net/manual/en/function.ucfirst.php