PHP 8 reference · Multibyte String Functions
PHP mb_convert_case() Function
Change the case of a string with Unicode rules: upper, lower, title case or case folding for comparisons.
PHP 8 Since 4.3
Syntax
mb_convert_case(string $string, int $mode, ?string $encoding = null): string
Parameters
| Parameter | Description |
|---|---|
string |
The input string. |
mode |
MB_CASE_UPPER, MB_CASE_LOWER, MB_CASE_TITLE, MB_CASE_FOLD and their _SIMPLE variants. |
encoding optional |
The character encoding; defaults to mb_internal_encoding() (UTF-8). |
Return value
The converted string.
Examples
<?php
echo mb_convert_case("élise de la tour", MB_CASE_TITLE), "\n";
Output
Élise De La Tour
<?php
$a = mb_convert_case("Straße", MB_CASE_FOLD);
$b = mb_convert_case("STRASSE", MB_CASE_FOLD);
var_dump($a === $b);
Output
bool(true)
Version history
| Version | Change |
|---|---|
| PHP 4.3 | Added |
In other languages
str.title()· Pythonstr.casefold()· Python
Related
mb_strtolower()· Convert a string to lowercase, including letters outside ASCII such as É, Ü and Cyrillic. The Unicode-aware strtolower().mb_strtoupper()· Convert a string to uppercase, including letters outside ASCII such as é, ß and Cyrillic. The Unicode-aware strtoupper().ucwords()· Uppercase the first letter of each word in a string. By default words are separated by spaces, tabs and new lines.- PHP Strings · tutorial