mb_convert_case

(PHP 4 >= 4.3.0, PHP 5, PHP 7)

mb_convert_case对字符串进行大小写转换

说明

mb_convert_case ( string $str , int $mode [, string $encoding = mb_internal_encoding() ] ) : string

对一个 string 进行大小写转换,转换模式由 mode 指定。

参数

str

要被转换的 string

mode

转换的模式。它可以是 MB_CASE_UPPERMB_CASE_LOWERMB_CASE_TITLE 的其中一个。

encoding

encoding 参数为字符编码。如果省略,则使用内部字符编码。

返回值

mode 指定的模式转换 string 大小写后的版本。

Unicode

和类似 strtolower()strtoupper() 的标准大小写转换函数相比, 大小写转换的执行根据 Unicode 字符属性的基础。 因此此函数的行为不受语言环境(locale)设置的影响,能够转换任意具有“字母”属性的字符,例如元音变音A(Ä)。

更多关于 Unicode 属性的信息,请查看 » http://www.unicode.org/unicode/reports/tr21/

范例

Example #1 mb_convert_case() 例子

<?php
$str 
"mary had a Little lamb and she loved it so";
$str mb_convert_case($strMB_CASE_UPPER"UTF-8");
echo 
$str// 输出 MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
$str mb_convert_case($strMB_CASE_TITLE"UTF-8");
echo 
$str// 输出 Mary Had A Little Lamb And She Loved It So
?>

Example #2 非拉丁 UTF-8 文本的mb_convert_case() 例子

<?php
$str 
"Τάχιστη αλώπηξ βαφής ψημένη γη, δρασκελίζει υπέρ νωθρού κυνός";
$str mb_convert_case($strMB_CASE_UPPER"UTF-8");
echo 
$str// 输出 ΤΆΧΙΣΤΗ ΑΛΏΠΗΞ ΒΑΦΉΣ ΨΗΜΈΝΗ ΓΗ, ΔΡΑΣΚΕΛΊΖΕΙ ΥΠΈΡ ΝΩΘΡΟΎ ΚΥΝΌΣ
$str mb_convert_case($strMB_CASE_TITLE"UTF-8");
echo 
$str// 输出 Τάχιστη Αλώπηξ Βαφήσ Ψημένη Γη, Δρασκελίζει Υπέρ Νωθρού Κυνόσ
?>

参见

相关文章
php 多字节字符串 函数 对字符串进行大小写转换php 多字节字符串 函数 转换字符的编码php 多字节字符串 函数 convert kana one from another zen kaku han kaku and more php 多字节字符串 函数 转换一个或多个变量的字符编码php 多字节字符串 函数 returns position and length of a matched part of the multibyte regular expression for a predefined multibyte stringphp 多字节字符串 函数 returns the matched part of a multibyte regular expressionphp 多字节字符串 函数 set start point of next regular expression matchphp 多字节字符串 函数 在输出缓冲中转换字符编码的回调函数php 多字节字符串 函数 获取 mime 字符串php 多字节字符串 函数 set/get character encoding for multibyte regexphp 多字节字符串 函数 set/get the default options for mbregex functionsphp 多字节字符串 函数 大小写不敏感地查找字符串在另一个字符串中首次出现的位置php 多字节字符串 函数 大小写不敏感地查找字符串在另一个字符串里的首次出现php 多字节字符串 函数 大小写不敏感地查找指定字符在另一个字符串中最后一次的出现php 多字节字符串 函数 大小写不敏感地在字符串中查找一个字符串最后出现的位置php 多字节字符串 函数 查找字符串在另一个字符串里的首次出现php 多字节字符串 函数 使字符串小写php 字符串 函数 转换字符串第一个字节为 0 255 之间的值php 字符串 函数 二进制安全比较字符串(不区分大小写)php xml 解析器函数 将用 utf 8 方式编码的 iso 8859 1 字符串转换成单字节的 iso 8859 1 字符串。
关注编程学问公众号