php 汉语转拼音 可以只转首字母,也可以设置utf8,gbk

WBOY
Release: 2016-06-13 13:06:44
Original
933 people have browsed it

php 中文转拼音 可以只转首字母,也可以设置utf8,gbk

='5.0') ? array_combine($_TDataKey, $_TDataValue) : _Array_Combine($_TDataKey, $_TDataValue);
arsort($_Data);
reset($_Data);

if($_Code != 'gb2312') $_String = _U2_Utf8_Gb($_String);
$_Res = '';
for($i=0; $i160) { $_Q = ord(substr($_String, ++$i, 1)); $_P = $_P*256 + $_Q - 65536; }
$_Res .= _Pinyin($_P, $_Data,$isInitial);
}
return preg_replace("/[^a-z0-9]*/", '', $_Res);
}

function _Pinyin($_Num, $_Data,$isInitial)
{
if ($_Num>0 && $_Num-10247) return '';
else {
foreach($_Data as $k=>$v){ if($v>6);
$_String .= chr(0x80 | $_C & 0x3F);
}elseif($_C >12);
$_String .= chr(0x80 | $_C>>6 & 0x3F);
$_String .= chr(0x80 | $_C & 0x3F);
} elseif($_C >18);
$_String .= chr(0x80 | $_C>>12 & 0x3F);
$_String .= chr(0x80 | $_C>>6 & 0x3F);
$_String .= chr(0x80 | $_C & 0x3F);
}
return iconv('UTF-8', 'GB2312', $_String);
}

function _Array_Combine($_Arr1, $_Arr2)
{
for($i=0; $i
Copy after login
?
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!