Autor Zpráva
H13
Profil
Ahoj potřeboval bych převést řetězec resp. převést první písmeno řetězce na velké písmeno.

Funkce ucfirst() je parádní, neumí však české znaky.

díky za jakoukoliv radu
H13
Profil
tohle vypadá dobře, ještě to překopu do češtiny


function my_mb_ucfirst($str, $e='UTF-8') {
if (function_exists('mb_strtoupper')) {
$fc = mb_strtoupper(mb_substr($str, 0, 1, $e), $e);
return $fc.mb_substr($str, 1, mb_strlen($str, $e), $e);
}
else {
$latin1 = utf8_decode($str);
$first_lc = $latin1[0];
$first_uc = strtr($first_lc,
"abcdefghýijklmnopqrstuvwxyz".
"x9Cx9AxE0xE1xE2xE3".
"xE4xE5xE6xE7xE8xE9".
"xEAxEBxECxEDxEExEF".
"xF0xF1xF2xF3xF4xF5".
"xF6xF8xF9xFAxFBxFC".
"xFExFF",
"ABCDEFGHÝIJKLMNOPQRSTUVWXYZ".
"x8Cx8AxC0xC1xC2xC3xC4".
"xC5xC6xC7xC8xC9xCAxCB".
"xCCxCDxCExCFxD0xD1xD2".
"xD3xD4xD5xD6xD8xD9xDA".
"xDBxDCxDEx9F");
if ($first_uc == $first_lc) return $str; // No change happened
else return utf8_encode($first_uc).substr($str, strlen(utf8_encode($first_lc)));
}
}
Toto téma je uzamčeno. Odpověď nelze zaslat.

0