mb_convert_case
Changes the case of a string, aware of multibyte characters.
Syntax
mb_convert_case(string $string, int $mode, ?string $encoding = null): stringParameters
| Parameter | Type | Description |
|---|---|---|
| $string | string | The input string. |
| $mode | int | The mode: `MB_CASE_UPPER`, `MB_CASE_LOWER`, `MB_CASE_TITLE`. |
| $encoding | ?string | Optional. 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.