Valorile întoarse

A case folded version of string converted in the
way specified by mode.

Unicode

By contrast to the standard case folding functions such as
strtolower() and strtoupper(),
case folding is performed on the basis of the Unicode character
properties. Thus the behaviour of this function is not affected
by locale settings and it can convert any characters that have
'alphabetic' property, such as A-umlaut (Ä).

Exemple

Example #1 mb_convert_case() example

<?php$str = "mary had a Little lamb and she loved it so";$str = mb_convert_case($str, MB_CASE_UPPER, "UTF-8");echo $str; // Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO$str = mb_convert_case($str, MB_CASE_TITLE, "UTF-8");echo $str; // Prints Mary Had A Little Lamb And She Loved It So?>

User Contributed Notes 7 notes

as the previouly posted version of this function doesn't handle UTF-8 characters, I simply tried to replace ucfirst to mb_convert_case, but then any previous case foldings were lost while looping through delimiters. So I decided to do an mb_convert_case on the input string (it also deals with words is uppercase wich may also be problematic when doing case-sensitive search), and do the rest of checking after that.

As with mb_convert_case, words are capitalized, I also added lowercase convertion for the exceptions, but, for the above mentioned reason, I left ucfirst unchanged.

Now it works fine for utf-8 strings as well, except for string delimiters followed by an UTF-8 character ("Mcádám" is unchanged, while "mcdunno's" is converted to "McDunno's" and "ökrös-TÓTH éDUa" in also put in the correct form)

I use it for checking user input on names and addresses, so exceptions list contains some hungarian words too.

if (in_array(mb_strtoupper($word, "UTF-8"), $exceptions)){// check exceptions list for any words that should be in upper case$word = mb_strtoupper($word, "UTF-8"); } elseif (in_array(mb_strtolower($word, "UTF-8"), $exceptions)){// check exceptions list for any words that should be in upper case$word = mb_strtolower($word, "UTF-8"); }

For CZECH characters:<?php$text = mb_convert_case($text, MB_CASE_LOWER, "Windows-1251");?>The right encoding Windows-1250 is not valid (see the list mb_list_encodings), but Windows-1251 will do the same 100%. The function strtolower() ignores czech characters with diacritics.