Home > Backend Development > PHP Tutorial > php字符串截取有关问题【送分题】

php字符串截取有关问题【送分题】

WBOY
Release: 2016-06-13 10:21:23
Original
837 people have browsed it

php字符串截取问题【送分题】
页面从数据库获取了 title 字段
然后在 前台页面显示
比如字符串 为: "php字符串截取问题得得得顶顶顶顶顶顶【送分题】"

现在需要 判断 如果 超过10个字符 后面 用“...“ 代替
如果少于10个字符的话 则 不用...

php字符串截取问题... 这样

------解决方案--------------------

PHP code
$title="php字符串截取问题得得得顶顶顶顶顶顶【送分题】";$len=mb_strlen($title,'utf-8');echo $len>10 ? mb_substr($title,0,10,'utf-8').'...' : $title;<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template