Created
October 11, 2012 13:51
-
-
Save pongo/e85d04913c937dfbd498 to your computer and use it in GitHub Desktop.
[php] Как сделать первую букву заглавной
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (!function_exists('mb_ucfirst') && extension_loaded('mbstring')) { | |
| /** | |
| * mb_ucfirst - преобразует первый символ в верхний регистр | |
| * @param string $str - строка | |
| * @param string $encoding - кодировка, по-умолчанию UTF-8 | |
| * @return string */ | |
| function mb_ucfirst($str, $encoding='windows-1251') { | |
| $str = mb_ereg_replace('^[\ ]+', '', $str); | |
| $str = mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding). | |
| mb_substr($str, 1, mb_strlen($str), $encoding); | |
| return $str; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment