Last active
November 7, 2022 13:25
-
-
Save yarliganfatih/d72afc6ed8c8ecac7ff7b250c2102bf8 to your computer and use it in GitHub Desktop.
ucfirst function with utf-8 turkish chars
This file contains 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
<? | |
function iConverterTurkish($str, $dir="upper"){ | |
$low = array('ı','i','ğ','ü','ş','ö','ç'); | |
$up = array('I','İ','Ğ','Ü','Ş','Ö','Ç'); | |
return $dir=="upper" ? | |
str_replace($low, $up, $str) : | |
str_replace($up, $low, $str) ; | |
} | |
function ucfirstTurkish($str) { | |
$tmp = preg_split("//u", $str, 2, PREG_SPLIT_NO_EMPTY); | |
return | |
strtoupper(iConverterTurkish($tmp[0],"upper")). | |
strtolower(iConverterTurkish($tmp[1],"lower")); | |
} | |
echo ucfirstTurkish("iyİlikLIdırÖ"); // return İyiliklıdırö | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment