note 109572 added to function.ucfirst

From: Date: Mon, 30 Jul 2012 08:47:22 +0000
Subject: note 109572 added to function.ucfirst
Groups: php.notes 
Request: Send a blank email to php-notes+get-189460@lists.php.net to get a copy of this message
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; } ---- Server IP: 69.147.83.197 Probable Submitter: 95.16.170.171 ---- Manual Page -- http://www.php.net/manual/en/function.ucfirst.php Edit -- https://master.php.net/note/edit/109572 Del: integrated -- https://master.php.net/note/delete/109572/integrated Del: useless -- https://master.php.net/note/delete/109572/useless Del: bad code -- https://master.php.net/note/delete/109572/bad+code Del: spam -- https://master.php.net/note/delete/109572/spam Del: non-english -- https://master.php.net/note/delete/109572/non-english Del: in docs -- https://master.php.net/note/delete/109572/in+docs Del: other reasons-- https://master.php.net/note/delete/109572 Reject -- https://master.php.net/note/reject/109572 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#189460) next »