The mb_strtolower Function
The mb_strtolower
function converts all characters in a string to lowercase,
considering the specifics of multibyte encodings. It accepts the string as the first parameter,
and the encoding as the second (optional) parameter. If the encoding is not specified, the internal script encoding is used.
Syntax
mb_strtolower(string, [encoding]);
Example
Convert a string with Cyrillic characters to lowercase:
<?php
echo mb_strtolower('Привет МИР');
?>
Code execution result:
'привет мир'
Example
Convert a string with UTF-8 encoding specified:
<?php
echo mb_strtolower('HELLO WORLD', 'UTF-8');
?>
Code execution result:
'hello world'
Example
Comparison with the regular strtolower
for multibyte strings:
<?php
$str = 'Привет Мир';
echo strtolower($str) . '<br>';
echo mb_strtolower($str, 'UTF-8');
?>
Code execution result:
'Привет Мир'
'привет мир'
See Also
-
the
mb_strtoupper
function,
which converts a string to uppercase -
the
strtolower
function,
which converts a string to lowercase