PHP缩短显示的文字数量 [英] php shorten amount of text displayed

查看:56
本文介绍了PHP缩短显示的文字数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图限制从MySQL显示的文本/数据量,而不是MySQL LIMIT,但像大多数博客一样,将其限制在实际页面上.在某些文本点之后,它们只会显示...更多,我知道在PHP中有一个函数可以执行此操作,但是我不记得它的名称,有人可以帮我解决这个问题吗?

I am trying to limit the amount of text/data is being shown from MySQL not MySQL LIMIT but limiting it on the actual page like most blogs do. After certain text point they just display ...more, I know there is a function to do this in PHP but I am unable to remember its name could some one help me out with it?

推荐答案

if(strlen($text)>1000){
    $text=substr($text,0,1000).' Read more';
}

您应该了解它也可以剪切单词和标签.

you should understand that it can cut words and tags too.

这篇关于PHP缩短显示的文字数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆