Encodera

Thanks for reading!

Donate to the site — we work hard for you.

PHP reference

mb_convert_case

Changes the case of a string, aware of multibyte characters.

Syntax

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

Parameters

ParameterTypeDescription
$stringstringThe input string.
$modeintThe mode: `MB_CASE_UPPER`, `MB_CASE_LOWER`, `MB_CASE_TITLE`.
$encoding?stringOptional. The encoding.

Return value

stringThe string in the new case.

Examples

Every word capitalised:

<?php
 
echo mb_convert_case('анна-мария иванова', MB_CASE_TITLE);

Output:

Анна-Мария Иванова

Notes

ucwords() does not work for non-ASCII letters — use the MB_CASE_TITLE mode.

See also

  • mb_strtoupper — Converts a string to uppercase.
  • mb_strtolower — Converts a string to lowercase for any alphabet.
  • ucwords — Uppercases the first letter of every word.

In the tutorial

  • Strings — Working with strings in PHP — quotes, concatenation, length, searching, replacing and multibyte functions.

Thanks for reading!

Donate to the site — we work hard for you.