PHP mb_convert_case() Function
The mb_convert_case() function is an inbuilt function in PHP that is used to perform case folding on the string and converted it into the specified mode of string.
Syntax:
string mb_convert_case(
string $string,
int $mode,
string $encoding = null
)
Parameters: This function accepts three parameters that are described below:
- $string: This parameter defines the string that needs to convert into a specified mode.
- $mode: This parameter holds the mode of conversion. The mode of conversion can be:
- MB_CASE_UPPER
- MB_CASE_LOWER
- MB_CASE_TITLE
- MB_CASE_FOLD
- MB_CASE_UPPER_SIMPLE
- MB_CASE_LOWER_SIMPLE
- MB_CASE_TITLE_SIMPLE
- MB_CASE_FOLD_SIMPLE
- $encoding: This parameter describes the character encoding. If this parameter value is omitted or null, the internal character encoding value will be used.
Return Value: This parameter returns the case folded version of the string converted into the specified mode.
Example 1: The following code demonstrates the PHP mb_convert_case() function.
PHP
<?php
$str = "welcome to geeksforgeeks" ;
$upperCase = mb_convert_case(
$str , MB_CASE_UPPER, "UTF-8" );
echo $upperCase ;
$lowerCase = mb_convert_case(
$upperCase , MB_CASE_LOWER, "UTF-8" );
echo "\n" . $lowerCase ;
?>
|
Output
WELCOME TO GEEKSFORGEEKS
welcome to geeksforgeeks
Example 2: The following code demonstrates another example of the PHP mb_convert_case() function.
PHP
<?php
$str = "welcome to geeksforgeeks" ;
$upperCase = mb_convert_case(
$str , MB_CASE_TITLE, "UTF-8" );
echo $upperCase ;
$lowerCase = mb_convert_case(
$upperCase , MB_CASE_UPPER_SIMPLE, "UTF-8" );
echo "\n" . $lowerCase ;
?>
|
Output
Welcome To Geeksforgeeks
WELCOME TO GEEKSFORGEEKS
Reference: https://www.php.net/manual/en/function.mb-convert-case.php
Last Updated :
02 Sep, 2022
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...