找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 232|回复: 0

[cms教程] 织梦获得首字母方法,并实现文章列表按首字母归类

[复制链接]

该用户从未签到

发表于 2021-2-16 09:53:25 | 显示全部楼层 |阅读模式

您需要 登录 才可以下载或查看,没有账号?立即注册

×
   
方法一,织梦默认有这个函数,在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...

   
内容已隐藏,请关注公众号输入验证码查看

               
验证码 

  

本帖支持关注公众号查看

【无套路  无套路  无套路 扫描二维码关注公众号发送【验证码】收到验证码 在上面输入点击提交查看即可显示隐藏内容】

回复

使用道具 举报

网站地图|页面地图|Archiver|手机版|小黑屋|找资源 |网站地图

GMT+8, 2025-5-13 11:53

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表