ЛУЧШЕЕ решение
function gen_string($string,$min=10,$clean=false) {
$string = str_replace('<br />',' ',$string);
$string = str_replace('</p>',' ',$string);
$string = str_replace('<li>',' ',$string);
$string = str_replace('</li>',' ',$string);
$text = trim(strip_tags($string));
if(strlen($text)>$min) {
$blank = strpos($text,' ');
if($blank) {
# limit plus last word
$extra = strpos(substr($text,$min),' ');
$max = $min+$extra;
$r = substr($text,0,$max);
if(strlen($text)>=$max && !$clean) $r=trim($r,'.').'...';
} else {
# if there are no spaces
$r = substr($text,0,$min).'...';
}
} else {
# if original length is lower than limit
$r = $text;
}
return trim($r);
}
просто передайте html через функцию gen_string ()