note 109744 added to function.ucfirst

From: Date: Thu, 16 Aug 2012 04:00:32 +0000
Subject: note 109744 added to function.ucfirst
Groups: php.notes 
Request: Send a blank email to php-notes+get-190095@lists.php.net to get a copy of this message
This is a better alternative to the previously suggested approaches. <?php if(!function_exists('mb_ucfirst')) { function mb_ucfirst($str, $encoding = NULL) { if($encoding === NULL) { $encoding = mb_internal_encoding(); } return mb_substr(mb_strtoupper($str, $encoding), 0, 1, $encoding) . mb_substr($str, 1, mb_strlen($str)-1, $encoding); } } $test_cases = array('test', 'šuo', 'äh', 'été indien'); header('Content-Type: text/plain'); foreach($test_cases as $tc) { echo mb_ucfirst($tc) . PHP_EOL; } ?> Test output: Test Šuo Äh Été indien ---- Server IP: 69.147.83.197 Probable Submitter: 49.144.127.203 ---- Manual Page -- http://www.php.net/manual/en/function.ucfirst.php Edit -- https://master.php.net/note/edit/109744 Del: integrated -- https://master.php.net/note/delete/109744/integrated Del: useless -- https://master.php.net/note/delete/109744/useless Del: bad code -- https://master.php.net/note/delete/109744/bad+code Del: spam -- https://master.php.net/note/delete/109744/spam Del: non-english -- https://master.php.net/note/delete/109744/non-english Del: in docs -- https://master.php.net/note/delete/109744/in+docs Del: other reasons-- https://master.php.net/note/delete/109744 Reject -- https://master.php.net/note/reject/109744 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#190095) next »