user198989 user198989 - 1 year ago 111
PHP Question

Ucfirst doesnt work on non-english characters

I'm trying to make the first letter uppercase in a string. It works fine for english letters, but unfortunetely, it doesn't work on non-english chars, for example

echo ucfirst("çağla");

What is the correct way to make ucfirst work properly on all words including non-english chars ?

Answer Source

Thanks, I finally found this working function as Stony's suggestion.

function myucfirst($str) {
    $fc = mb_strtoupper(mb_substr($str, 0, 1));
    return $fc.mb_substr($str, 1);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download