方法一,织梦默认有这个函数,在include/inc/inc_fun_funAdmin.PHP中.即SpGetPinyin() 但他只能得到全拼,没法得到首字母, 用法举例 $pingyin=GetPinyin($row['title',,0]1); $a=substr(GetPinyin($row['title',),0]1);//得到拼音首字母 方法二,如果你只想得到首字母,不需要全拼,还可以用以下函数得到首字母 if (ord($row['title',)>128) { //汉字开头 $letter=getfirstchar2($row['title',); }else if(ord($row['title',)>=48 and ord($row['title',) $letter=iconv_substr($title,0]1,'utf-8'); } else if(ord($row['title',)>=65 and ord($row['title',) $letter=iconv_substr($row['title',,0]1,'utf-8'); }else if(ord($row['title',)>=97 and ord($row['title',) $letter=iconv_substr($row['title',,0]1,'utf-8'); $letter=strtoupper($letter);//字母转换成大写 } print_r($letter);exit; function getfirstchar2($s0){ $s=iconv("UTF-8","gb2312", $s0); $asc=ord($s{0})*256+ord($s{1})-65536; if($asc>=-20319 and $asc if($asc>=-20283 and $asc if($asc>=-19775 and $asc if($asc>=-19218 and $asc if($asc>=-18710 and $asc if($asc>=-18526 and $asc if($asc>=-18...
内容已隐藏,请关注公众号输入验证码查看
本帖支持关注公众号查看
【无套路 无套路 无套路 扫描二维码关注公众号发送【验证码】收到验证码 在上面输入点击提交查看即可显示隐藏内容】
|