- mb_substr: documentation ( source)
- mb_strtoupper: documentation ( source)
- ord: documentation ( source)
- ucfirst: documentation ( source)
<?php
function ufirst( $str ) {
$octetCode = ord( $str );
// See https://en.wikipedia.org/wiki/ASCII#Printable_characters
if ( $octetCode < 96 ) {
// Assume this is an uppercase/uncased ASCII character
return (string)$str;
} elseif ( $octetCode < 128 ) {
// Assume this is a lowercase/uncased ASCII character
return ucfirst( $str );
}
$first = mb_substr( $str, 0, 1 );
return ( strlen( $first ) !== 1 )
// Assume this is a multibyte character and mb_internal_encoding() is appropriate
? mb_strtoupper( $first ) . mb_substr( $str, 1 )
// Assume this is a non-multibyte character and LC_CASE is appropriate
: ucfirst( $str );
}
$str = "ალევის_სამების_მონასტერი.jpg";
$str = ufirst($str);
echo $str;
?>