The mb_strtolower Function

The mb_strtolower function converts all characters in a string to lowercase, considering the features of multibyte encodings. It accepts a string as the first parameter, and an encoding as the second (optional) one. If the encoding is not specified, the script's internal encoding is used.

Syntax

phpmb_strtolower(string, [encoding]);

Example

Let's convert a string with Cyrillic characters to lowercase:

php<?php
  echo mb_strtolower('Привет МИР');
?>

Code execution result:

php'привет мир'

Example

Convert a string specifying the UTF-8 encoding:

php<?php
  echo mb_strtolower('HELLO WORLD', 'UTF-8');
?>

Code execution result:

php'hello world'

Example

Comparison with the regular strtolower for multibyte strings:

php<?php
  $str = 'Привет Мир';
  echo strtolower($str) . '<br>';
  echo mb_strtolower($str, 'UTF-8');
?>

Code execution result:

php'Привет Мир'
'привет мир'

See Also

  • the mb_strtoupper function,
    which converts a string to uppercase
  • the strtolower function,
    which converts a string to lowercase