note 103907 modified in function.ucfirst by danbrown

From: Date: Tue, 17 May 2011 14:12:23 +0000
Subject: note 103907 modified in function.ucfirst by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-179793@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})).substr($stri,2); else return ucfirst($stri); } ?> 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: <?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. http://php.net/manual/en/function.ucfirst.php

« previous php.notes (#179793) next »