Last active
August 29, 2015 14:02
-
-
Save ademalp/4583bf7b7462679282e2 to your computer and use it in GitHub Desktop.
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
| class STR | |
| { | |
| private static $tr_lo = array("ı", "ğ", "ü", "ş", "i", "ö", "ç"); | |
| private static $tr_up = array("I", "Ğ", "Ü", "Ş", "İ", "Ö", "Ç"); | |
| public static function strtolower($str, $encoding = "UTF-8") | |
| { | |
| return mb_convert_case(str_replace(self::$tr_up, self::$tr_lo, $str), MB_CASE_LOWER, $encoding); | |
| } | |
| public static function strtoupper($str, $encoding = "UTF-8") | |
| { | |
| return mb_convert_case(str_replace(self::$tr_lo, self::$tr_up, $str), MB_CASE_UPPER, $encoding); | |
| } | |
| public static function ucwords($str, $encoding = "UTF-8") | |
| { | |
| $return = array(); | |
| $words = str_word_count($str, 1, implode(self::$tr_lo) . implode(self::$tr_up)); | |
| foreach ($words as $word) { | |
| $return[] = self::ucfirst(self::strtolower($word), true, $encoding); | |
| } | |
| return implode($return, " "); | |
| } | |
| public static function ucfirst($str, $lower_str_end = false, $encoding = "UTF-8") | |
| { | |
| $first_letter = self::strtoupper(mb_substr($str, 0, 1, $encoding), $encoding); | |
| if ($lower_str_end) { | |
| $str_end = self::strtolower(mb_substr($str, 1, mb_strlen($str, $encoding), $encoding), $encoding); | |
| } else { | |
| $str_end = mb_substr($str, 1, mb_strlen($str, $encoding), $encoding); | |
| } | |
| $str = $first_letter . $str_end; | |
| return $str; | |
| } | |
| } |
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
| IĞÜŞİÖÇ IĞÜŞİÖÇ DENEME | |
| ığüşiöç ığüşiöç deneme | |
| Iğüşiöç Iğüşiöç Deneme | |
| IĞÜŞİÖÇ ığüşiöç deneme | |
| Iğüşiöç ığüşiöç deneme |
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
| $metin = "IĞÜŞİÖÇ ığüşiöç deneme"; | |
| echo STR::strtoupper($metin); | |
| echo "\n"; | |
| echo STR::strtolower($metin); | |
| echo "\n"; | |
| echo STR::ucwords($metin); | |
| echo "\n"; | |
| echo STR::ucfirst($metin); | |
| echo "\n"; | |
| echo STR::ucfirst($metin,true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment