Encodera

Thanks for reading!

Donate to the site — we work hard for you.

PHP reference

mb_strtolower

Converts a string to lowercase for any alphabet.

Syntax

mb_strtolower(string $string, ?string $encoding = null): string

Parameters

ParameterTypeDescription
$stringstringThe source string.
$encoding?stringOptional. The encoding; UTF-8 by default.

Return value

stringThe string in lowercase.

Examples

Cyrillic and Latin letters:

<?php
 
echo mb_strtolower('ПРИВЕТ, World');

Output:

привет, world

A 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

Related recipes

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.