Rumah > Artikel > pembangunan bahagian belakang > php取出字符串(包括汉字)首字母函数
//取出首字母函数
function getfirstchar($s0){
if(ord($s0)>="1" and ord($s0)//$s=iconv("UTF-8","gb2312", $s0); 如果需要转换为utf-8的话
$s=$s0;//无需转换的情况
$asc=ord($s{0})*256+ord($s{1})-65536;
if($asc>=-20319 and $ascif($asc>=-20283 and $ascif($asc>=-19775 and $ascif($asc>=-19218 and $ascif($asc>=-18710 and $ascif($asc>=-18526 and $ascif($asc>=-18239 and $ascif($asc>=-17922 and $ascif($asc>=-17417 and $ascif($asc>=-16474 and $ascif($asc>=-16212 and $ascif($asc>=-15640 and $ascif($asc>=-15165 and $ascif($asc>=-14922 and $ascif($asc>=-14914 and $ascif($asc>=-14630 and $ascif($asc>=-14149 and $ascif($asc>=-14090 and $ascif($asc>=-13318 and $ascif($asc>=-12838 and $ascif($asc>=-12556 and $ascif($asc>=-11847 and $ascif($asc>=-11055 and $ascreturn 0;
}
echo getfirstchar("你好");
?>
以上就介绍了php取出字符串(包括汉字)首字母函数,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。