页面从数据库获取了 title 字段
然后在 前台页面显示
比如字符串 为: "php字符串截取问题得得得顶顶顶顶顶顶【送分题】"现在需要 判断 如果 超过10个字符 后面 用“...“ 代替
如果少于10个字符的话 则 不用...php字符串截取问题... 这样
然后在 前台页面显示
比如字符串 为: "php字符串截取问题得得得顶顶顶顶顶顶【送分题】"现在需要 判断 如果 超过10个字符 后面 用“...“ 代替
如果少于10个字符的话 则 不用...php字符串截取问题... 这样
$len=mb_strlen($title,'utf-8');
echo $len>10 ? mb_substr($title,0,10,'utf-8').'...' : $title;
好久没有写php 了