【发布时间】:2011-09-08 12:36:01
【问题描述】:
我得到了这个功能:
function shorter($text, $chars_limit) {
if (strlen($text) > $chars_limit)
return substr($text, 0, strrpos(substr($text, 0, $chars_limit), " ")).'...';
else return $text;
}
如果我使用echo shorter($input, 11),它可以正常工作,但如果输入中有一些空格,否则输入看起来像:
wwwwwwwwwwww
该函数会将其更改为:
...(3 个点)。
我不想把它改成这样:
www ...
您对如何重建此脚本有任何想法吗? 提前谢谢你。
【问题讨论】: