I got a problem to make upper letters in php.
I tried this function:
function strtouper_srbija($string) {
$low=array("č" => "Č", "ž" => "Ž", "Š" => "š","Đ" => "đ","Č" => "č");
return strtoupper(strtr($string,$low));
}
and tried to use with some POST data from html page,text filed,but no succes,so if you have solutions,will be fine..
Also, I found solution with CSS, with text-transform: uppercase;
, but will be fine to have PHP example.
Couldn't you use mb_strtoupper?
http://www.php.net/manual/en/function.mb-strtoupper.php
<?php
$str = "Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός";
$str = mb_strtoupper($str, 'UTF-8');
echo $str; // Prints ΤΆΧΙΣΤΗ ΑΛΏΠΗΞ ΒΑΦΉΣ ΨΗΜΈΝΗ ΓΗ, ΔΡΑΣΚΕΛΊΖΕΙ ΥΠΈΡ ΝΩΘΡΟΎ ΚΥΝΌΣ
?>
Loop trough your string using a foreach
loop:
function strtouper_srbija($string) {
$letters = array("č" => "Č", "ž" => "Ž", "š" => "Š", "đ" => "Đ", "ć" => "Ć");
$newString = $string;
foreach ($letters as $lower=>$upper){
$newString = str_replace($lower, $upper, $newString);
}
return $newString;
}
Other way from Glavić
function strtouper_srbija($string) {
$letters = array("č" => "Č", "ž" => "Ž", "š" => "Š", "đ" => "Đ", "ć" => "Ć");
return str_replace(array_keys($letters), array_values($letters), $string);
}
echo strtouper_srbija('testiram ščćžđ ŠČĆŽĐ');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With