mb_strtolower
Converts a string to lowercase for any alphabet.
Syntax
mb_strtolower(string $string, ?string $encoding = null): stringParameters
| Parameter | Type | Description |
|---|---|---|
| $string | string | The source string. |
| $encoding | ?string | Optional. The encoding; UTF-8 by default. |
Return value
stringThe string in lowercase.
Examples
Cyrillic and Latin letters:
<?php
echo mb_strtolower('ПРИВЕТ, World');Output:
привет, worldA case-insensitive search:
<?php
$text = 'Купить Чай';
var_dump(str_contains(mb_strtolower($text), 'чай'));Output:
bool(true)Notes
Use it for any user text: strtolower() leaves non-ASCII letters alone.
See also
- mb_strtoupper — Converts a string to uppercase.
- strtolower — Converts ASCII letters to lowercase.
Related recipes
In the tutorial
- Strings — Working with strings in PHP — quotes, concatenation, length, searching, replacing and multibyte functions.