note 113855 added to function.ucfirst

From: Date: Tue, 10 Dec 2013 08:55:37 +0000
Subject: note 113855 added to function.ucfirst
Groups: php.notes 
Request: Send a blank email to php-notes+get-197889@lists.php.net to get a copy of this message
Еще один вариант "mb_ucfirst" <?php header('content-type: text/plain; charset=utf8;'); function mb_ucfirst($str) { if (preg_match('/[a-z]/ui', $str[0])) return ucfirst($str); $first = mb_strtoupper($str[0].$str[1], 'utf8'); $str[0] = $first[0]; $str[1] = $first[1]; return $str; } echo ucfirst('строка в utf8 ucfirst')."\n"; echo mb_ucfirst('строка в utf8 mb_ucfirst')."\n"; echo mb_ucfirst('développeur mb_ucfirst')."\n"; echo mb_ucfirst('éveloppeur mb_ucfirst')."\n"; ?> На выходе: строка в utf8 ucfirst Строка в utf8 mb_ucfirst Développeur mb_ucfirst Éveloppeur mb_ucfirst Только для кодировки utf8. ---- Server IP: 72.52.91.14 Probable Submitter: 72.52.91.14 ---- Manual Page -- http://php.net/manual/en/function.ucfirst.php Edit -- https://master.php.net/note/edit/113855 Del: integrated -- https://master.php.net/note/delete/113855/integrated Del: useless -- https://master.php.net/note/delete/113855/useless Del: bad code -- https://master.php.net/note/delete/113855/bad+code Del: spam -- https://master.php.net/note/delete/113855/spam Del: non-english -- https://master.php.net/note/delete/113855/non-english Del: in docs -- https://master.php.net/note/delete/113855/in+docs Del: other reasons-- https://master.php.net/note/delete/113855 Reject -- https://master.php.net/note/reject/113855 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#197889) next »