Código PHP:
function introtext($text) {
if (strlen($text) > 45) {
$pos = strpos($text, ' ', "45");
if ((!$pos) || ($pos > 45)) {
$pos = 45;
}
$text = substr($text, 0, $pos + 1) . " ...";
return $text;
}else{
return $text;
}
}
Gracias.