PHP提取中文首字母
程序员文章站
2022-05-28 14:30:34
复制代码 代码如下: function pykey( $py_key) ...
复制代码 代码如下:
<?
function pykey( $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;
}
function pys( $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;
?>
上一篇: Java粒子特效喷薄的彩球
下一篇: 浅析C++中的深拷贝与浅拷贝