下面的脚本将获取$ description中的内容摘要,并且如果在前50个字符中找到句点,它将返回前50个字符和句点。然而,缺陷是,当内容中没有句点时,它只返回第一个字符。substr strpos帮助
function get_cat_desc($description){
$the_description = strip_tags($description);
if(strlen($the_description) > 50)
return SUBSTR($the_description,0,STRPOS($the_description,".",50)+1);
else return $the_description;}
我想使它所以,如果无期被发现,它返回,直到后50个字符(所以它不会削减字断)和第一空空间追加” ... “
这个很好用。谢谢! – 2011-02-12 23:22:37