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

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

mb_convert_case(string $string, int $mode, ?string $encoding = null): string

Parameters

ParameterDescription
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

Title case with accentsTry it yourself
<?php
echo mb_convert_case("élise de la tour", MB_CASE_TITLE), "\n";

Output

Élise De La Tour
Case-insensitive comparisonTry it yourself
<?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

VersionChange
PHP 4.3Added

In other languages

Was this page helpful?