限制表格单元格中显示的字符数 [英] Limiting number of characters displayed in table cell

查看:207
本文介绍了限制表格单元格中显示的字符数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个将数据添加到表格单元格的PHP循环。但是,我希望将静态大小应用于表格单元格,因此如果返回的数据超过单元格内容,我希望多余的字符被截断并以...

I have a PHP loop that adds data into a table cell. However, I want to apply a static size to the table cell, so if more data is returned than can fit inside the cell I want the excess characters to be cut off and end with a "..."

例如,一个数据条目有270个字符,但只有前100个显示在表格单元格中。按照...

For example, one data entry has 270 characters, but only the first 100 are displayed in the table cell. Follow by a "..."

关于如何做到这一点的任何想法?

Any ideas on how to do this?

谢谢! p>

Thanks!

推荐答案

if (strlen($str) > 100) $str = substr($str, 0, 100) . "...";

这篇关于限制表格单元格中显示的字符数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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