Ver Mensaje Individual
  #2 (permalink)  
Antiguo 05/12/2005, 14:14
dreglad
Invitado
 
Mensajes: n/a
Puntos:
Hace tiempo escribí esta función que me resultó útil.. es un algoritmo bastante burdo, lógicamente hay más eficientes, pero sirve muy bien..

Código PHP:
function texto_muestra($txt$limite 30) {
    
$txt preg_replace("/\s{2,}/"" "trim(strip_tags($txt)));
    
$txt str_replace(" "" "$txt);
    
preg_match("/(.+)\s(.+)$/"substr($txt0$limite), $matches);
    return 
trim($matches[1]) . "...";