PHP 每日一函数 — 字符串函数 convert_cyr_string ()

返回指定的字符 convert_cyr_string ()

convert_cyr_string ( string $str , string $from , string $to ) : string

此函数将给定的字符串从一种 Cyrillic 字符转换成另一种,返回转换之后的字符串。此函数可安全用于二进制对象。

参数:
$str 要转换的字符。
$from 单个字符,代表源 Cyrillic 字符集。
$to 单个字符,代表了目标 Cyrillic 字符集。

支持的类型有:
   k - koi8-r
   w - windows-1251
   i - iso8859-5
   a - x-cp866
   d - x-cp866
   m - x-mac-cyrillic

返回值:
返回转换后的字符串。

$str = 'Hello world! ???';
echo $str.'<br>';  //Hello world! ???
$newStr = convert_cyr_string($str,'w','m');
echo $newStr;  //Hello world! ???

不太明白此函数可以用在什么地方,望大佬解答。

本作品采用《CC 协议》,转载必须注明作者和本文链接
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!