$title = "hello word";
echo mb_ucfirst( $title ); // return "Hello word";
Created
February 5, 2017 10:59
-
-
Save lenivene/eff7d98baf86f1af60b9354bfa6d7019 to your computer and use it in GitHub Desktop.
First character uppercase
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
<?php | |
if( ! function_exists( 'mb_ucfirst' ) ){ | |
function mb_ucfirst( $string = '', $encoding = "UTF-8" ){ | |
if( empty( $string ) ) | |
return false; | |
$strlen = mb_strlen( $string, $encoding ); | |
$firstChar = mb_substr( $string, 0, 1, $encoding ); | |
$end_Char = mb_substr( $string, 1, $strlen - 1, $encoding ); | |
return mb_strtoupper( $firstChar, $encoding ) . $end_Char; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment