Ver Mensaje Individual
  #2 (permalink)  
Antiguo 24/01/2011, 13:59
Avatar de Nazari
Nazari
 
Fecha de Ingreso: febrero-2010
Ubicación: Canarias - Tenerife
Mensajes: 62
Antigüedad: 14 años, 2 meses
Puntos: 7
Respuesta: Sustituir string largo por mismo string abreviado con tres puntos alfinal

Buenas, te monte esta funcion es muy sencilla de usar.

Código PHP:
Ver original
  1. function largo($texto){
  2.    
  3.     //Maximo de caracteres permitidos
  4.     $maximo = 10;
  5.    
  6.     //Le restamos 3 para añadir los puntos
  7.     $cortar = $maximo - 3;
  8.    
  9.     //Comprobamos que la longuitud no exede el maximo
  10.     if(strlen($texto) > $maximo){
  11.         $return = substr( $texto, 0, $cortar )."...";
  12.     }
  13.    
  14.     //Devolvemos el resultado
  15.     return $return;
  16. }

Saludos
__________________
Nazarí González
http://www.nazariglez.com - @Nazariglez