【发布时间】:2012-08-26 18:02:10
【问题描述】:
在 PHP 中,我试图以最大字符限制显示一行内容,所以
$result = mysql_query("SELECT * FROM `news`");
$length = 350; // Show first 350 characters of row, then cut it off
while($row = mysql_fetch_array($result)) {
$show = nl2br(substr($row['content'], 0, $length));
}
P.S: 代码标签搞砸了,$length 不在 while 循环中。
使用 while() 语句来增加 strpos 的 $length,不起作用。
有什么建议吗?
我想做这个,万一线路有链接,它不会把它切断,直到换到新的线路,它知道它已经完成,所以链接就完成了。
【问题讨论】:
-
text-overflow可能有用。
标签: php mysql select while-loop