PHP提取中文首字母

2018-10-15 17:58

阅读:445

复制代码 代码如下:
<?
functionpykey($py_key)
{
$pinyin=65536+pys($py_key);
if(45217<=$pinyin&&$pinyin<=45252)
{
$zimu=A;
return$zimu;
}
if(45253<=$pinyin&&$pinyin<=45760)
{
$zimu=B;
return$zimu;
}
if(45761<=$pinyin&&$pinyin<=46317)
{
$zimu=C;
return$zimu;
}
if(46318<=$pinyin&&$pinyin<=46825)
{
$zimu=D;
return$zimu;
}
if(46826<=$pinyin&&$pinyin<=47009)
{
$zimu=E;
return$zimu;
}
if(47010<=$pinyin&&$pinyin<=47296)
{
$zimu=F;
return$zimu;
}
if(47297<=$pinyin&&$pinyin<=47613)
{
$zimu=G;
return$zimu;
}
if(47614<=$pinyin&&$pinyin<=48118)
{
$zimu=H;
return$zimu;
}
if(48119<=$pinyin&&$pinyin<=49061)
{
$zimu=J;
return$zimu;
}
if(49062<=$pinyin&&$pinyin<=49323)
{
$zimu=K;
return$zimu;
}
if(49324<=$pinyin&&$pinyin<=49895)
{
$zimu=L;
return$zimu;
}
if(49896<=$pinyin&&$pinyin<=50370)
{
$zimu=M;
return$zimu;
}
if(50371<=$pinyin&&$pinyin<=50613)
{
$zimu=N;
return$zimu;
}
if(50614<=$pinyin&&$pinyin<=50621)
{
$zimu=O;
return$zimu;
}
if(50622<=$pinyin&&$pinyin<=50905)
{
$zimu=P;
return$zimu;
}
if(50906<=$pinyin&&$pinyin<=51386)
{
$zimu=Q;
return$zimu;
}
if(51387<=$pinyin&&$pinyin<=51445)
{
$zimu=R;
return$zimu;
}
if(51446<=$pinyin&&$pinyin<=52217)
{
$zimu=S;
return$zimu;
}
if(52218<=$pinyin&&$pinyin<=52697)
{
$zimu=T;
return$zimu;
}
if(52698<=$pinyin&&$pinyin<=52979)
{
$zimu=W;
return$zimu;
}
if(52980<=$pinyin&&$pinyin<=53640)
{
$zimu=X;
return$zimu;
}
if(53689<=$pinyin&&$pinyin<=54480)
{
$zimu=Y;
return$zimu;
}
if(54481<=$pinyin&&$pinyin<=62289)
{
$zimu=Z;
return$zimu;
}
$zimu=$py_key;
return$zimu;
}
functionpys($pysa)
{
$pyi=;
$i=0;
for(;$i<strlen($pysa);$i++)
{
$_obfuscate_8w=ord(substr($pysa,$i,1));
if(160<$_obfuscate_8w)
{
$_obfuscate_Bw=ord(substr($pysa,$i++,1));
$_obfuscate_8w=$_obfuscate_8w*256+$_obfuscate_Bw-65536;
}
$pyi.=$_obfuscate_8w;
}
return$pyi;
}
$letter=pykey(中华人民共和国);
echo$letter;
?>


评论


亲,登录后才可以留言!